mirror of
https://github.com/irmen/prog8.git
synced 2024-12-27 05:29:38 +00:00
added cx16 banking example
This commit is contained in:
parent
85e87dfe2e
commit
c11a52b278
@ -53,6 +53,10 @@ compilation targets, and not all targets even have banking or support this. As a
|
|||||||
on the Commander X16, prog8 will use the JSRFAR kernal routine for this. On the Commodore 128, a similar call exists.
|
on the Commander X16, prog8 will use the JSRFAR kernal routine for this. On the Commodore 128, a similar call exists.
|
||||||
Other compilation targets don't have banking or prog8 doesn't yet support automatic bank selection on them.
|
Other compilation targets don't have banking or prog8 doesn't yet support automatic bank selection on them.
|
||||||
|
|
||||||
|
There's a "banking" (not financial) example for the Commander X16 that shows a possible application
|
||||||
|
of the romsub with bank support, check out the `bank example code <https://github.com/irmen/prog8/tree/master/examples/cx16/banking>`_ .
|
||||||
|
|
||||||
|
|
||||||
Notice that the symbol for this routine in the assembly source code will still be defined as usual.
|
Notice that the symbol for this routine in the assembly source code will still be defined as usual.
|
||||||
The bank number is not translated into assembly (only as a comment)::
|
The bank number is not translated into assembly (only as a comment)::
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
add example for cx16 that compiles and loads libraries in different ram banks and calls romsub from rom and ram banks automatically
|
|
||||||
|
|
||||||
add support for banked romsubs on the C64 as well (banks basic/kernal rom in/out)
|
add support for banked romsubs on the C64 as well (banks basic/kernal rom in/out)
|
||||||
|
|
||||||
rename 'romsub' to 'extsub' ? keep romsub as alias?
|
rename 'romsub' to 'extsub' ? keep romsub as alias?
|
||||||
|
13
examples/cx16/banking/Makefile
Normal file
13
examples/cx16/banking/Makefile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
.PHONY: all clean zip run
|
||||||
|
|
||||||
|
all: PROGRAM.PRG
|
||||||
|
|
||||||
|
PROGRAM.PRG: library1.asm library2.asm program.p8
|
||||||
|
64tass --case-sensitive --ascii --long-branch library1.asm -o LIBRARY1.PRG
|
||||||
|
64tass --case-sensitive --ascii --long-branch library2.asm -o LIBRARY2.PRG
|
||||||
|
prog8c -target cx16 program.p8
|
||||||
|
mv program.prg PROGRAM.PRG
|
||||||
|
|
||||||
|
run: PROGRAM.PRG
|
||||||
|
x16emu -scale 2 -run -prg PROGRAM.PRG
|
||||||
|
|
26
examples/cx16/banking/library1.asm
Normal file
26
examples/cx16/banking/library1.asm
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
.cpu 'w65c02'
|
||||||
|
.enc 'none'
|
||||||
|
|
||||||
|
* = $a000
|
||||||
|
|
||||||
|
CHROUT = $ffd2
|
||||||
|
|
||||||
|
message_pointer = $02
|
||||||
|
|
||||||
|
routine1:
|
||||||
|
lda #<message
|
||||||
|
sta message_pointer
|
||||||
|
lda #>message
|
||||||
|
sta message_pointer+1
|
||||||
|
ldy #0
|
||||||
|
- lda (message_pointer),y
|
||||||
|
beq +
|
||||||
|
jsr CHROUT
|
||||||
|
iny
|
||||||
|
bne -
|
||||||
|
+ lda #<12345
|
||||||
|
ldy #>12345
|
||||||
|
rts
|
||||||
|
|
||||||
|
message:
|
||||||
|
.text "hello from routine 1",13,0
|
26
examples/cx16/banking/library2.asm
Normal file
26
examples/cx16/banking/library2.asm
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
.cpu 'w65c02'
|
||||||
|
.enc 'none'
|
||||||
|
|
||||||
|
* = $a000
|
||||||
|
|
||||||
|
CHROUT = $ffd2
|
||||||
|
|
||||||
|
message_pointer = $02
|
||||||
|
|
||||||
|
routine1:
|
||||||
|
lda #<message
|
||||||
|
sta message_pointer
|
||||||
|
lda #>message
|
||||||
|
sta message_pointer+1
|
||||||
|
ldy #0
|
||||||
|
- lda (message_pointer),y
|
||||||
|
beq +
|
||||||
|
jsr CHROUT
|
||||||
|
iny
|
||||||
|
bne -
|
||||||
|
+ lda #<44444
|
||||||
|
ldy #>44444
|
||||||
|
rts
|
||||||
|
|
||||||
|
message:
|
||||||
|
.text "hello from routine 2",13,0
|
34
examples/cx16/banking/program.p8
Normal file
34
examples/cx16/banking/program.p8
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
%import textio
|
||||||
|
%import diskio
|
||||||
|
|
||||||
|
%option no_sysinit
|
||||||
|
%zeropage basicsafe
|
||||||
|
|
||||||
|
main {
|
||||||
|
romsub @bank 4 $A000 = lib_routine1(ubyte value @A) clobbers(X) -> uword @AY
|
||||||
|
romsub @bank 5 $A000 = lib_routine2(ubyte value @A) clobbers(X) -> uword @AY
|
||||||
|
romsub @bank 10 $C09F = audio_init() -> bool @A
|
||||||
|
|
||||||
|
sub start() {
|
||||||
|
|
||||||
|
; load the example libraries in hiram banks 4 and 5
|
||||||
|
cx16.rambank(4)
|
||||||
|
void diskio.load("library1.prg", $a000)
|
||||||
|
cx16.rambank(5)
|
||||||
|
void diskio.load("library2.prg", $a000)
|
||||||
|
|
||||||
|
cx16.rambank(1)
|
||||||
|
|
||||||
|
; call a routine from the Audio rom bank:
|
||||||
|
bool success = audio_init()
|
||||||
|
|
||||||
|
; call hiram banked loaded routines:
|
||||||
|
cx16.r0 = lib_routine1(11)
|
||||||
|
txt.print_uw(cx16.r0)
|
||||||
|
txt.nl()
|
||||||
|
|
||||||
|
cx16.r0 = lib_routine2(99)
|
||||||
|
txt.print_uw(cx16.r0)
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user