CPCWiki forum

General Category => Programming => Topic started by: Trebmint on 20:17, 24 September 13

Title: Assembling to ROM in Winape
Post by: Trebmint on 20:17, 24 September 13
Assembling using the built in assember in Winape is it possible to assemble to a ROM page.


Having not coded either ROM or using Winape, having only written to RAM im a bit confused as to how to do it.


The project I have to Plus+++ a existing game. Its working nicely too with lots of new colours etc and upgraded graphics. Developing wise Ive used the built Winape assembler directly to a block of 2k spare ram in the main 64k. Ive been saving the whole thing as a Snapshot as I dont have a full dissambly to recompile etc


So is it possible to direct assemble to cartridge ROM?????? Please


Else I'd have to release as a snapshot file and thats no fun.... I want a .CRT


Rob
Title: Re: Assembling to ROM in Winape
Post by: Bryce on 20:36, 24 September 13
The Cartridge ROMs are like a standard expansion ROM (see several guides as discussed in another current thread). The only difference is that they are not limited to 16K, they can be up to 512K and appear as ROM Number 128 onwards.

Bryce.
Title: Re: Assembling to ROM in Winape
Post by: Trebmint on 20:56, 24 September 13
So how do I direct compile to a ROM using Winape assembler? What are the compiler directives
Title: Re: Assembling to ROM in Winape
Post by: TFM on 21:19, 24 September 13
I'm not acquainted to this assembler. But I would do the following.

- Assemble part in 16 KB blocks (target address would usually be &C000-&FFFF)

- Save these single 16 KB blocks

- Use a HEX Editor to make a big file out of all these 16 KB Blocks

- Use the program BIN2CPR [nb]or similar name[/nb] to generate a CPR


I dunno if there is a more easy way. But you can ask Devilmarkus to implement this new desired feature in his JavaCPC  ;)
Title: Re: Assembling to ROM in Winape
Post by: arnoldemu on 08:52, 25 September 13
TFM's way is one way, it's a bit of a pain with larger files.

16K sections, join together with copy /b, then use bin2cpr to generate the cpr file.

The alternative, is to use a "Cart File system". I've implemented something you are welcome to use.

A tool on the pc joins multiple files together, and inserts a "directory" of sorts at the start of the cart.
To load each part you use the function in rom page 0. My approach is similar to No$cash utility but without basic, firmware and amsdos.

If you're interested PM me and I'll send you the latest version to use with some instructions.

I plan to take this approach first.
Title: Re: Assembling to ROM in Winape
Post by: TFM on 18:12, 25 September 13
Quote from: arnoldemu on 08:52, 25 September 13
A tool on the pc joins multiple files together,


I made such a tool for the CPC side. For my Cartridge developments I use only the CPC, a PC is not needed. And it's quick process, in case all the assembly (and debugging) was done before.

Title: Re: Assembling to ROM in Winape
Post by: Executioner on 07:10, 22 October 13
Hi Rob,

You can use the write direct command to write directly to a selected ROM address. Not sure if it works for ROMS 128..255 though...

From the WinAPE help file:

write direct    Write direct allows direct output to emulator memory. The full syntax is:
write direct [lower_rom[,upper_rom[,ram_bank]]].
Set lower_rom to -1 to disable or 0 to enable the lower_rom, upper_rom to -1 to disable, or an upper ROM number and ram_bank to an expansion bank number #C0 to #FF.

Cheers,
Richard


Title: Re: Assembling to ROM in Winape
Post by: AMSDOS on 09:04, 28 December 17
Trying to make a small ROM in Winape using the Write Direct which I think is correct, though when I do a reset, it gets as far as printing my Palette Installed Message before going into this ongoing Reset Loop. Suspect it's code I've obtained from the AA53 Feature Article, but I'm not completely sure  :'(




org &c000


write direct -1,1,#C0


defb 1
defb 1,1,1


defw nametable


jp initialize


jp prog1


ret


.nametable
defb "PA"
defb "L"+#80
defb 0


.initialize
push hl
push de
ld hl,message
call print


ld de,100
sbc hl,de

pop de
pop hl
scf
ret


.message
defb "Pallette Installed",0


.print ld a,(hl)
cp 0
ret z
call #bb5a
inc hl
jr print


.prog1 ld a,0
ld bc,1111
call &bc32
ld a,1
ld bc,2626
call &bc32
ld bc,1111
call &bc38
ret
Title: Re: Assembling to ROM in Winape
Post by: IanS on 13:07, 28 December 17
You don't have a name defined for your "prog1" command in .nametable.

You are also trying to reserve some memory "sbc hl,de", but you then restore hl from the stack. So you won't be reserving aby memory.

I don't think either of those things should cause a reset loop, but you should probably fix them.
Title: Re: Assembling to ROM in Winape
Post by: roudoudou on 13:41, 28 December 17
Quote from: AMSDOS on 09:04, 28 December 17
Trying to make a small ROM in Winape using the Write Direct which I think is correct, though when I do a reset, it gets as far as printing my Palette Installed Message before going into this ongoing Reset Loop. Suspect it's code I've obtained from the AA53 Feature Article, but I'm not completely sure  :'(




   org &c000


   write direct -1,1,#C0


   defb 1
   defb 1,1,1


   defw nametable


   jp initialize


   jp prog1


   ret


.nametable
   defb "PA"
   defb "L"+#80
   defb 0


.initialize
   push hl
   push de
   ld hl,message
   call print


   ld de,100
   sbc hl,de
   
   pop de
   pop hl
   scf
   ret


.message
   defb "Pallette Installed",0


.print   ld a,(hl)
   cp 0
   ret z
   call #bb5a
   inc hl
   jr print


.prog1   ld a,0
   ld bc,1111
   call &bc32
   ld a,1
   ld bc,2626
   call &bc32
   ld bc,1111
   call &bc38
   ret



- Use only "write direct 1" to write the rom 1 or "write direct -1,1"
- You must know winape cant write to rom 1 if there is not already a rom 1, dont ask me why...



Title: Re: Assembling to ROM in Winape
Post by: AMSDOS on 23:39, 28 December 17

Quote from: IanS on 13:07, 28 December 17You don't have a name defined for your "prog1" command in .nametable.You are also trying to reserve some memory "sbc hl,de", but you then restore hl from the stack. So you won't be reserving aby memory.I don't think either of those things should cause a reset loop, but you should probably fix them.



Ok, I've added a Name to go with the Initialize routine.


The program published in AA53 looks a little bit dodgy, in their case their PUSHing HL & DE, Printing the Text (which is incorrect as they don't have a print routine, I added one earlier), and then reserving some memory before POPping HL/DE from the Stack. I've since moved that after the POP has occurred from the Stack.

Quote from: roudoudou on 13:41, 28 December 17

- Use only "write direct 1" to write the rom 1 or "write direct -1,1"
- You must know winape cant write to rom 1 if there is not already a rom 1, dont ask me why...




Write Direct 1 is an out of range error, so I'm using write direct -1,1, this is what I've currently got:




org #C000


write direct -1,1


defb 1
defb 1,1,1


defw nametable


jp initialize


jp prog1


ret


.nametable
defb "SETUP PALETT"
defb "E"+#80
defb "PA"
defb "L"+#80
defb 0


.initialize
push hl
push de


ld hl,message
call print


pop de
pop hl


ld de,100
sbc hl,de

scf
ret


.message
defb "Palette Installed",0


.print ld a,(hl)
cp 0
ret z
call #bb5a
inc hl
jr print




.prog1 ld a,0
ld bc,#0b0b
call #bc32
ld a,1
ld bc,#1a1a
call #bc32
ld bc,#0b0b
call #bc38
ret



Sadly I've never written a ROM before and after I've made the changes, the problem is still occurring. When I pause to go into the Winape Debugger Select Any, Goto ROM 1 & select &C0, it looks like my code is going somewhere where it's overwriting something else, I don't know why as Winape is telling me that area is supposed to be Empty.


I'm also confused as to how I'm supposed to write out a ROM file, I use the Debugger to save a file with the Extension .ROM, though that doesn't look correct. Help!  :'(
Title: Re: Assembling to ROM in Winape
Post by: roudoudou on 00:04, 29 December 17


do you have a rom file selected in the upper slot 1 ?


in 6128 default configuration, upper 1 is empty. Create a 16384 zeroed file and load it in the slot 1. So you will be able to write in the upper 1
Title: Re: Assembling to ROM in Winape
Post by: SOS on 00:10, 29 December 17
Quote from: AMSDOS on 23:39, 28 December 17





org #C000


write direct -1,1


defb 1
defb 1,1,1


defw nametable


jp initialize


jp prog1


ret


.nametable
defb "SETUP PALETT"
defb "E"+#80
defb "PA"
defb "L"+#80
defb 0


.initialize
push hl
push de


ld hl,message
call print


pop de
pop hl


ld de,100
sbc hl,de

scf
ret


.message
defb "Palette Installed",0


.print ld a,(hl)
cp 0
ret z
call #bb5a
inc hl
jr print




.prog1 ld a,0
ld bc,#0b0b
call #bc32
ld a,1
ld bc,#1a1a
call #bc32
ld bc,#0b0b
call #bc38
ret


Sadly I've never written a ROM before and after I've made the changes, the problem is still occurring. When I pause to go into the Winape Debugger Select Any, Goto ROM 1 & select &C0,

it looks like my code is going somewhere where it's overwriting something else, I don't know why as Winape is telling me that area is supposed to be Empty.

I'm getting this, with an empty Slot 1 (no file):  (btw. why do you select &c0?)

[attach=2]

Quote from: AMSDOS on 23:39, 28 December 17
I'm also confused as to how I'm supposed to write out a ROM file, I use the Debugger to save a file with the Extension .ROM, though that doesn't look correct. Help!  :'( [/font]

Try:
write direct -1,7

; AMSDOS 6128
org #whatever
ld a,(007)
cp "JAMES"
ret z

close
save "AMSDOSP.ROM",#c000,#3fff,0

Title: Re: Assembling to ROM in Winape
Post by: IanS on 01:27, 29 December 17
Quote from: AMSDOS on 23:39, 28 December 17I've since moved that after the POP has occurred from the Stack.
So you are now putting the wrong value in DE. It would exit being set to 100.

You needs something like this:
.initialize
    push de
    push hl

    ld hl,message
    call print

    pop hl

    ld de,100
    sbc hl,de

    pop de
   
    scf
    ret
Title: Re: Assembling to ROM in Winape
Post by: AMSDOS on 01:43, 29 December 17

Well I've done what @roudoudou (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1714) has suggested and created a zero out ROM file. I've put that into Upper 1 slot and compiled my Winape assembly file, initially I had "write direct -1,1", though that still wasn't working, so I changed to "write direct -1,1,#c0" and the program compiles to where it needs to go. I saved that in the Winape Debugger as a 16384 byte ROM file, which now seems to be working.



   org #C000


   write direct -1,1,#c0


   defb 1
   defb 1,1,1


   defw nametable


   jp initialize


   jp prog1


   ret


.nametable
   defb "Setup Palett"
   defb "e"+#80
   defb "PA"
   defb "L"+#80
   defb 0


.initialize
   push hl
   push de


   ld hl,message
   call print


   pop de
   pop hl


   ld de,100
   sbc hl,de
   
   scf
   ret


.message
   defb "Palette Installed",0


.print   ld a,(hl)
   cp 0
   ret z
   call #bb5a
   inc hl
   jr print




.prog1   ld a,0
   ld bc,#0b0b
   call #bc32
   ld a,1
   ld bc,#1a1a
   call #bc32
   ld bc,#0b0b
   call #bc38
   ret



Guess if I don't rectify the 100 in DE issue, the stack will fill out and crash the system.


EDIT: Attached correct ROM so DE won't have 100 in it.


@SOS (http://www.cpcwiki.eu/forum/index.php?action=profile;u=941) - I select &C0 because I'm using an Upper ROM where the program resides at &C000 and when I say write direct -1,1,#C0 the program compiles to &C000 in Upper ROM slot 1.
Title: Re: Assembling to ROM in Winape
Post by: fgbrain on 19:10, 13 May 18
Not sure if this is the right thread...


I want to try building a cpr cartridge from Winape assembler.


Is there any special command for this??
What is the execution address of a cartridge? I suspect &0000 at rom 0????





Title: Re: Assembling to ROM in Winape
Post by: roudoudou on 19:30, 13 May 18
Quote from: fgbrain on 19:10, 13 May 18
Not sure if this is the right thread...


I want to try building a cpr cartridge from Winape assembler.


Is there any special command for this??
What is the execution address of a cartridge? I suspect &0000 at rom 0? ???
Winape does not assemble in cartridge, as far as i know BUT it can assemble to ROM

Plus the memory configuration is not dependant of global configuration (WTF?)

I suggest you to build a real CPR with any tool and run CPR
A CPC+ run at #0000 interrupt disabled and IM 1 as default with ROM 0 connected lower AND upper in #C000note: The upper ROM is ROM 1 if there is more than 1 ROM in your CPR. Else ROM 0
Title: Re: Assembling to ROM in Winape
Post by: evenmore on 12:13, 03 March 22
Just in case anyone is reading this and wants to assemble their own ROM through WinAPE, I have fixed a few bugs in the above Palette ROM code.

I added a linefeed and carriage return after the ROM name so it appears correctly on boot above the BASIC 1.1 line.

I changed the JP (Jump) commands to CALL commands so that they return correctly.

I added PUSH and POP commands before and after the palette modification commands so that the ROM will return to the BASIC prompt correctly. Before it would just hang.

; WRITE TO ROM
; MAKE 16k ZERO'D FILE EMPTY.ROM
;   IN LINUX
;   dd if=/dev/zero of=Empty.ROM count=1 bs=16384

; SELECT EMPTY.ROM FILE IN WINAPE MEMORY SETTINGS, UPPER 1
; ASSEMBLE WITH WINAPE
; write direct -1,1,#c0 COMPILES TO ROM FILE INSTEAD OF MEMORY

   org #C000

   write direct -1,1,#c0

   defb 1
   defb 1,1,1

   defw nametable
   call initialize
   call prog1

   ret

.nametable
   defb "Setup Palett"
   defb "e"+#80
   defb "PA"
   defb "L"+#80
   defb 0

.initialize
   push hl
   push de

   ld hl,message
   call print

   pop de
   pop hl
  
   scf
   ret

.message
   defb " Palette Installed",10,13,0

.print  
   ld a,(hl)
   cp 0
   ret z
   call #bb5a
   inc hl
   jr print

.prog1  
   push hl
   push de

   ld a,0
   ld bc,#0b0b
   call #bc32
   ld a,1
   ld bc,#1a1a
   call #bc32
   ld bc,#0b0b
   call #bc38

   pop de
   pop hl
  
   ret
Powered by SMFPacks Menu Editor Mod