diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt index 5881c63c8..eaa5e9b44 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt @@ -104,15 +104,15 @@ internal class ProgramAndVarsGen( asmgen.out("+\t.word 0") asmgen.out("prog8_entrypoint\t; assembly code starts here") if(!options.noSysInit) - asmgen.out(" jsr ${compTarget.name}.init_system") - asmgen.out(" jsr ${compTarget.name}.init_system_phase2") + asmgen.out(" jsr sys.init_system") + asmgen.out(" jsr sys.init_system_phase2") } CbmPrgLauncherType.NONE -> { asmgen.out("; ---- program without basic sys call ----") asmgen.out("* = ${options.loadAddress.toHex()}") if(!options.noSysInit) - asmgen.out(" jsr ${compTarget.name}.init_system") - asmgen.out(" jsr ${compTarget.name}.init_system_phase2") + asmgen.out(" jsr sys.init_system") + asmgen.out(" jsr sys.init_system_phase2") } } } @@ -120,8 +120,8 @@ internal class ProgramAndVarsGen( asmgen.out("; ---- atari xex program ----") asmgen.out("* = ${options.loadAddress.toHex()}") if(!options.noSysInit) - asmgen.out(" jsr ${compTarget.name}.init_system") - asmgen.out(" jsr ${compTarget.name}.init_system_phase2") + asmgen.out(" jsr sys.init_system") + asmgen.out(" jsr sys.init_system_phase2") } } @@ -140,19 +140,19 @@ internal class ProgramAndVarsGen( if(options.floats) asmgen.out(" lda #4 | sta $01") // to use floats, make sure Basic rom is banked in asmgen.out(" jsr main.start") - asmgen.out(" jmp ${compTarget.name}.cleanup_at_exit") + asmgen.out(" jmp sys.cleanup_at_exit") } "c64" -> { asmgen.out(" jsr main.start | lda #31 | sta $01") if(!options.noSysInit) - asmgen.out(" jmp ${compTarget.name}.cleanup_at_exit") + asmgen.out(" jmp sys.cleanup_at_exit") else asmgen.out(" rts") } "c128" -> { asmgen.out(" jsr main.start | lda #0 | sta ${"$"}ff00") if(!options.noSysInit) - asmgen.out(" jmp ${compTarget.name}.cleanup_at_exit") + asmgen.out(" jmp sys.cleanup_at_exit") else asmgen.out(" rts") } diff --git a/compiler/res/prog8lib/c128/syslib.p8 b/compiler/res/prog8lib/c128/syslib.p8 index 51f9b8b57..6b28a3116 100644 --- a/compiler/res/prog8lib/c128/syslib.p8 +++ b/compiler/res/prog8lib/c128/syslib.p8 @@ -1,7 +1,8 @@ ; Prog8 definitions for the Commodore-128 ; Including memory registers, I/O registers, Basic and Kernal subroutines. -c64 { +cbm { + ; Commodore (CBM) common variables, vectors and kernal routines &ubyte TIME_HI = $a0 ; software jiffy clock, hi byte &ubyte TIME_MID = $a1 ; .. mid byte @@ -47,6 +48,99 @@ c64 { const uword Screen = $0400 ; to have this as an array[40*25] the compiler would have to support array size > 255 const uword Colors = $d800 ; to have this as an array[40*25] the compiler would have to support array size > 255 +; ---- kernal routines, these are the same as on the Commodore-64 (hence the same block name) ---- + +; STROUT --> use txt.print +; CLEARSCR -> use txt.clear_screen +; HOMECRSR -> use txt.home or txt.plot + +romsub $FA65 = IRQDFRT() clobbers(A,X,Y) ; default IRQ routine +romsub $FF33 = IRQDFEND() clobbers(A,X,Y) ; default IRQ end/cleanup + +; TODO c128 a bunch of kernal routines are missing here that are specific to the c128 + +romsub $FF81 = CINT() clobbers(A,X,Y) ; (alias: SCINIT) initialize screen editor and video chip +romsub $FF84 = IOINIT() clobbers(A, X) ; initialize I/O devices (CIA, SID, IRQ) +romsub $FF87 = RAMTAS() clobbers(A,X,Y) ; initialize RAM, tape buffer, screen +romsub $FF8A = RESTOR() clobbers(A,X,Y) ; restore default I/O vectors +romsub $FF8D = VECTOR(uword userptr @ XY, ubyte dir @ Pc) clobbers(A,Y) ; read/set I/O vector table +romsub $FF90 = SETMSG(ubyte value @ A) ; set Kernal message control flag +romsub $FF93 = SECOND(ubyte address @ A) clobbers(A) ; (alias: LSTNSA) send secondary address after LISTEN +romsub $FF96 = TKSA(ubyte address @ A) clobbers(A) ; (alias: TALKSA) send secondary address after TALK +romsub $FF99 = MEMTOP(uword address @ XY, ubyte dir @ Pc) -> uword @ XY ; read/set top of memory pointer +romsub $FF9C = MEMBOT(uword address @ XY, ubyte dir @ Pc) -> uword @ XY ; read/set bottom of memory pointer +romsub $FF9F = SCNKEY() clobbers(A,X,Y) ; scan the keyboard +romsub $FFA2 = SETTMO(ubyte timeout @ A) ; set time-out flag for IEEE bus +romsub $FFA5 = ACPTR() -> ubyte @ A ; (alias: IECIN) input byte from serial bus +romsub $FFA8 = CIOUT(ubyte databyte @ A) ; (alias: IECOUT) output byte to serial bus +romsub $FFAB = UNTLK() clobbers(A) ; command serial bus device to UNTALK +romsub $FFAE = UNLSN() clobbers(A) ; command serial bus device to UNLISTEN +romsub $FFB1 = LISTEN(ubyte device @ A) clobbers(A) ; command serial bus device to LISTEN +romsub $FFB4 = TALK(ubyte device @ A) clobbers(A) ; command serial bus device to TALK +romsub $FFB7 = READST() -> ubyte @ A ; read I/O status word +romsub $FFBA = SETLFS(ubyte logical @ A, ubyte device @ X, ubyte secondary @ Y) ; set logical file parameters +romsub $FFBD = SETNAM(ubyte namelen @ A, str filename @ XY) ; set filename parameters +romsub $FFC0 = OPEN() clobbers(X,Y) -> ubyte @Pc, ubyte @A ; (via 794 ($31A)) open a logical file +romsub $FFC3 = CLOSE(ubyte logical @ A) clobbers(A,X,Y) ; (via 796 ($31C)) close a logical file +romsub $FFC6 = CHKIN(ubyte logical @ X) clobbers(A,X) -> ubyte @Pc ; (via 798 ($31E)) define an input channel +romsub $FFC9 = CHKOUT(ubyte logical @ X) clobbers(A,X) ; (via 800 ($320)) define an output channel +romsub $FFCC = CLRCHN() clobbers(A,X) ; (via 802 ($322)) restore default devices +romsub $FFCF = CHRIN() clobbers(X, Y) -> ubyte @ A ; (via 804 ($324)) input a character (for keyboard, read a whole line from the screen) A=byte read. +romsub $FFD2 = CHROUT(ubyte char @ A) ; (via 806 ($326)) output a character +romsub $FFD5 = LOAD(ubyte verify @ A, uword address @ XY) -> ubyte @Pc, ubyte @ A, uword @ XY ; (via 816 ($330)) load from device +romsub $FFD8 = SAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) -> ubyte @ Pc, ubyte @ A ; (via 818 ($332)) save to a device +romsub $FFDB = SETTIM(ubyte low @ A, ubyte middle @ X, ubyte high @ Y) ; set the software clock +romsub $FFDE = RDTIM() -> ubyte @ A, ubyte @ X, ubyte @ Y ; read the software clock (A=lo,X=mid,Y=high) +romsub $FFE1 = STOP() clobbers(X) -> ubyte @ Pz, ubyte @ A ; (via 808 ($328)) check the STOP key (and some others in A) +romsub $FFE4 = GETIN() clobbers(X,Y) -> ubyte @Pc, ubyte @ A ; (via 810 ($32A)) get a character +romsub $FFE7 = CLALL() clobbers(A,X) ; (via 812 ($32C)) close all files +romsub $FFEA = UDTIM() clobbers(A,X) ; update the software clock +romsub $FFED = SCREEN() -> ubyte @ X, ubyte @ Y ; read number of screen rows and columns +romsub $FFF0 = PLOT(ubyte col @ Y, ubyte row @ X, ubyte dir @ Pc) -> ubyte @ X, ubyte @ Y ; read/set position of cursor on screen. Use txt.plot for a 'safe' wrapper that preserves X. +romsub $FFF3 = IOBASE() -> uword @ XY ; read base address of I/O devices + +; ---- end of C64 compatible ROM kernal routines ---- + +; ---- utilities ----- + +asmsub STOP2() -> ubyte @A { + ; -- check if STOP key was pressed, returns true if so. More convenient to use than STOP() because that only sets the carry status flag. + %asm {{ + txa + pha + jsr cbm.STOP + beq + + pla + tax + lda #0 + rts ++ pla + tax + lda #1 + rts + }} +} + +asmsub RDTIM16() -> uword @AY { + ; -- like RDTIM() but only returning the lower 16 bits in AY for convenience + %asm {{ + stx P8ZP_SCRATCH_REG + jsr cbm.RDTIM + pha + txa + tay + pla + ldx P8ZP_SCRATCH_REG + rts + }} +} + + +} + +c64 { + ; C64 I/O registers (VIC, SID, CIA) + ; the default locations of the 8 sprite pointers (store address of sprite / 64) &ubyte SPRPTR0 = 2040 &ubyte SPRPTR1 = 2041 @@ -196,95 +290,91 @@ c64 { ; ---- end of SID registers ---- -; ---- kernal routines, these are the same as on the Commodore-64 (hence the same block name) ---- +} -; STROUT --> use txt.print -; CLEARSCR -> use txt.clear_screen -; HOMECRSR -> use txt.home or txt.plot +c128 { +; ---- C128 specific registers ---- -romsub $FA65 = IRQDFRT() clobbers(A,X,Y) ; default IRQ routine -romsub $FF33 = IRQDFEND() clobbers(A,X,Y) ; default IRQ end/cleanup + &ubyte VM1 = $0A2C ; shadow for VUC $d018 in text mode + &ubyte VM2 = $0A2D ; shadow for VIC $d018 in bitmap screen mode + &ubyte VM3 = $0A2E ; starting page for VDC screen mem + &ubyte VM4 = $0A2F ; starting page for VDC attribute mem -; TODO c128 a bunch of kernal routines are missing here that are specific to the c128 -romsub $FF81 = CINT() clobbers(A,X,Y) ; (alias: SCINIT) initialize screen editor and video chip -romsub $FF84 = IOINIT() clobbers(A, X) ; initialize I/O devices (CIA, SID, IRQ) -romsub $FF87 = RAMTAS() clobbers(A,X,Y) ; initialize RAM, tape buffer, screen -romsub $FF8A = RESTOR() clobbers(A,X,Y) ; restore default I/O vectors -romsub $FF8D = VECTOR(uword userptr @ XY, ubyte dir @ Pc) clobbers(A,Y) ; read/set I/O vector table -romsub $FF90 = SETMSG(ubyte value @ A) ; set Kernal message control flag -romsub $FF93 = SECOND(ubyte address @ A) clobbers(A) ; (alias: LSTNSA) send secondary address after LISTEN -romsub $FF96 = TKSA(ubyte address @ A) clobbers(A) ; (alias: TALKSA) send secondary address after TALK -romsub $FF99 = MEMTOP(uword address @ XY, ubyte dir @ Pc) -> uword @ XY ; read/set top of memory pointer -romsub $FF9C = MEMBOT(uword address @ XY, ubyte dir @ Pc) -> uword @ XY ; read/set bottom of memory pointer -romsub $FF9F = SCNKEY() clobbers(A,X,Y) ; scan the keyboard -romsub $FFA2 = SETTMO(ubyte timeout @ A) ; set time-out flag for IEEE bus -romsub $FFA5 = ACPTR() -> ubyte @ A ; (alias: IECIN) input byte from serial bus -romsub $FFA8 = CIOUT(ubyte databyte @ A) ; (alias: IECOUT) output byte to serial bus -romsub $FFAB = UNTLK() clobbers(A) ; command serial bus device to UNTALK -romsub $FFAE = UNLSN() clobbers(A) ; command serial bus device to UNLISTEN -romsub $FFB1 = LISTEN(ubyte device @ A) clobbers(A) ; command serial bus device to LISTEN -romsub $FFB4 = TALK(ubyte device @ A) clobbers(A) ; command serial bus device to TALK -romsub $FFB7 = READST() -> ubyte @ A ; read I/O status word -romsub $FFBA = SETLFS(ubyte logical @ A, ubyte device @ X, ubyte secondary @ Y) ; set logical file parameters -romsub $FFBD = SETNAM(ubyte namelen @ A, str filename @ XY) ; set filename parameters -romsub $FFC0 = OPEN() clobbers(X,Y) -> ubyte @Pc, ubyte @A ; (via 794 ($31A)) open a logical file -romsub $FFC3 = CLOSE(ubyte logical @ A) clobbers(A,X,Y) ; (via 796 ($31C)) close a logical file -romsub $FFC6 = CHKIN(ubyte logical @ X) clobbers(A,X) -> ubyte @Pc ; (via 798 ($31E)) define an input channel -romsub $FFC9 = CHKOUT(ubyte logical @ X) clobbers(A,X) ; (via 800 ($320)) define an output channel -romsub $FFCC = CLRCHN() clobbers(A,X) ; (via 802 ($322)) restore default devices -romsub $FFCF = CHRIN() clobbers(X, Y) -> ubyte @ A ; (via 804 ($324)) input a character (for keyboard, read a whole line from the screen) A=byte read. -romsub $FFD2 = CHROUT(ubyte char @ A) ; (via 806 ($326)) output a character -romsub $FFD5 = LOAD(ubyte verify @ A, uword address @ XY) -> ubyte @Pc, ubyte @ A, uword @ XY ; (via 816 ($330)) load from device -romsub $FFD8 = SAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) -> ubyte @ Pc, ubyte @ A ; (via 818 ($332)) save to a device -romsub $FFDB = SETTIM(ubyte low @ A, ubyte middle @ X, ubyte high @ Y) ; set the software clock -romsub $FFDE = RDTIM() -> ubyte @ A, ubyte @ X, ubyte @ Y ; read the software clock (A=lo,X=mid,Y=high) -romsub $FFE1 = STOP() clobbers(X) -> ubyte @ Pz, ubyte @ A ; (via 808 ($328)) check the STOP key (and some others in A) -romsub $FFE4 = GETIN() clobbers(X,Y) -> ubyte @Pc, ubyte @ A ; (via 810 ($32A)) get a character -romsub $FFE7 = CLALL() clobbers(A,X) ; (via 812 ($32C)) close all files -romsub $FFEA = UDTIM() clobbers(A,X) ; update the software clock -romsub $FFED = SCREEN() -> ubyte @ X, ubyte @ Y ; read number of screen rows and columns -romsub $FFF0 = PLOT(ubyte col @ Y, ubyte row @ X, ubyte dir @ Pc) -> ubyte @ X, ubyte @ Y ; read/set position of cursor on screen. Use txt.plot for a 'safe' wrapper that preserves X. -romsub $FFF3 = IOBASE() -> uword @ XY ; read base address of I/O devices +; ---- C128 specific system utility routines: ---- -; ---- end of C64 compatible ROM kernal routines ---- - -; ---- utilities ----- - -asmsub STOP2() -> ubyte @A { - ; -- check if STOP key was pressed, returns true if so. More convenient to use than STOP() because that only sets the carry status flag. +asmsub disable_basic() clobbers(A) { %asm {{ - txa - pha - jsr c64.STOP - beq + - pla - tax + lda $0a04 ; disable BASIC shadow registers + and #$fe + sta $0a04 + + lda #$01 ; disable BASIC IRQ service routine + sta $12fd + + lda #$ff ; disable screen editor IRQ setup + sta $d8 + + lda #$b7 ; skip programmable function key check + sta $033c + + lda #$0e ; bank out BASIC ROM + sta $ff00 + rts + }} +} + +; ---- end of C128 specific system utility routines ---- + +} + +sys { + ; ------- lowlevel system routines -------- + + const ubyte target = 128 ; compilation target specifier. 64 = C64, 128 = C128, 16 = CommanderX16. + +asmsub init_system() { + ; Initializes the machine to a sane starting state. + ; Called automatically by the loader program logic. + ; This means that the BASIC, KERNAL and CHARGEN ROMs are banked in, + ; the VIC, SID and CIA chips are reset, screen is cleared, and the default IRQ is set. + ; Also a different color scheme is chosen to identify ourselves a little. + ; Uppercase charset is activated, and all three registers set to 0, status flags cleared. + %asm {{ + sei + cld lda #0 - rts -+ pla - tax - lda #1 + sta $ff00 ; select default bank 15 + jsr cbm.IOINIT + jsr cbm.RESTOR + jsr cbm.CINT + lda #6 + sta c64.EXTCOL + lda #7 + sta cbm.COLOR + lda #0 + sta c64.BGCOL0 + jsr disable_runstop_and_charsetswitch + clc + clv + cli rts }} } -asmsub RDTIM16() -> uword @AY { - ; -- like RDTIM() but only returning the lower 16 bits in AY for convenience +asmsub init_system_phase2() { %asm {{ - stx P8ZP_SCRATCH_REG - jsr c64.RDTIM - pha - txa - tay - pla - ldx P8ZP_SCRATCH_REG - rts + rts ; no phase 2 steps on the C128 }} } +asmsub cleanup_at_exit() { + ; executed when the main subroutine does rts + %asm {{ + jmp sys.enable_runstop_and_charsetswitch + }} +} -; ---- system utility routines that are essentially the same as on the C64: ----- asmsub disable_runstop_and_charsetswitch() clobbers(A) { %asm {{ lda #$80 @@ -314,9 +404,9 @@ asmsub set_irq(uword handler @AY, ubyte useKernal @Pc) clobbers(A) { sta _use_kernal sei lda #<_irq_handler - sta c64.CINV + sta cbm.CINV lda #>_irq_handler - sta c64.CINV+1 + sta cbm.CINV+1 cli rts _irq_handler jsr _irq_handler_init @@ -334,7 +424,7 @@ _modified jsr $ffff ; modified tax pla rti -+ jmp c64.IRQDFRT ; continue with normal kernal irq routine ++ jmp cbm.IRQDFRT ; continue with normal kernal irq routine _use_kernal .byte 0 @@ -386,10 +476,10 @@ IRQ_SCRATCH_ZPWORD2 .word 0 asmsub restore_irq() clobbers(A) { %asm {{ sei - lda #c64.IRQDFRT - sta c64.CINV+1 + lda #cbm.IRQDFRT + sta cbm.CINV+1 lda #0 sta c64.IREQMASK ; disable raster irq lda #%10000001 @@ -401,19 +491,19 @@ asmsub restore_irq() clobbers(A) { asmsub set_rasterirq(uword handler @AY, uword rasterpos @R0, ubyte useKernal @Pc) clobbers(A) { %asm {{ - sta _modified+1 - sty _modified+2 - lda #0 - adc #0 - sta set_irq._use_kernal + sta _modified+1 + sty _modified+2 + lda #0 + adc #0 + sta set_irq._use_kernal lda cx16.r0 ldy cx16.r0+1 sei jsr _setup_raster_irq lda #<_raster_irq_handler - sta c64.CINV + sta cbm.CINV lda #>_raster_irq_handler - sta c64.CINV+1 + sta cbm.CINV+1 cli rts @@ -421,8 +511,8 @@ _raster_irq_handler jsr set_irq._irq_handler_init _modified jsr $ffff ; modified jsr set_irq._irq_handler_end - lda #$ff - sta c64.VICIRQ ; acknowledge raster irq + lda #$ff + sta c64.VICIRQ ; acknowledge raster irq lda set_irq._use_kernal bne + ; end irq processing - don't use kernal's irq handling @@ -432,7 +522,7 @@ _modified jsr $ffff ; modified tax pla rti -+ jmp c64.IRQDFRT ; continue with kernal irq routine ++ jmp cbm.IRQDFRT ; continue with kernal irq routine _setup_raster_irq pha @@ -456,99 +546,13 @@ _setup_raster_irq }} } -} - -c128 { -; ---- C128 specific registers ---- - - &ubyte VM1 = $0A2C ; shadow for VUC $d018 in text mode - &ubyte VM2 = $0A2D ; shadow for VIC $d018 in bitmap screen mode - &ubyte VM3 = $0A2E ; starting page for VDC screen mem - &ubyte VM4 = $0A2F ; starting page for VDC attribute mem - - -; ---- C128 specific system utility routines: ---- - -asmsub init_system() { - ; Initializes the machine to a sane starting state. - ; Called automatically by the loader program logic. - ; This means that the BASIC, KERNAL and CHARGEN ROMs are banked in, - ; the VIC, SID and CIA chips are reset, screen is cleared, and the default IRQ is set. - ; Also a different color scheme is chosen to identify ourselves a little. - ; Uppercase charset is activated, and all three registers set to 0, status flags cleared. - %asm {{ - sei - cld - lda #0 - sta $ff00 ; select default bank 15 - jsr c64.IOINIT - jsr c64.RESTOR - jsr c64.CINT - lda #6 - sta c64.EXTCOL - lda #7 - sta c64.COLOR - lda #0 - sta c64.BGCOL0 - jsr c64.disable_runstop_and_charsetswitch - clc - clv - cli - rts - }} -} - -asmsub init_system_phase2() { - %asm {{ - rts ; no phase 2 steps on the C128 - }} -} - -asmsub cleanup_at_exit() { - ; executed when the main subroutine does rts - %asm {{ - jmp c64.enable_runstop_and_charsetswitch - }} -} - -asmsub disable_basic() clobbers(A) { - %asm {{ - lda $0a04 ; disable BASIC shadow registers - and #$fe - sta $0a04 - - lda #$01 ; disable BASIC IRQ service routine - sta $12fd - - lda #$ff ; disable screen editor IRQ setup - sta $d8 - - lda #$b7 ; skip programmable function key check - sta $033c - - lda #$0e ; bank out BASIC ROM - sta $ff00 - rts - }} -} - -; ---- end of C128 specific system utility routines ---- - -} - -sys { - ; ------- lowlevel system routines -------- - - const ubyte target = 128 ; compilation target specifier. 64 = C64, 128 = C128, 16 = CommanderX16. - - asmsub reset_system() { ; Soft-reset the system back to initial power-on Basic prompt. %asm {{ sei lda #0 sta $ff00 ; default bank 15 - jmp (c64.RESET_VEC) + jmp (cbm.RESET_VEC) }} } @@ -566,9 +570,9 @@ _loop lda P8ZP_SCRATCH_W1 ldx P8ZP_SCRATCH_B1 rts -+ lda c64.TIME_LO ++ lda cbm.TIME_LO sta P8ZP_SCRATCH_B1 -- lda c64.TIME_LO +- lda cbm.TIME_LO cmp P8ZP_SCRATCH_B1 beq - @@ -730,8 +734,8 @@ _longcopy %asm {{ lda #0 sta $ff00 ; default bank 15 - jsr c64.CLRCHN ; reset i/o channels - jsr c64.enable_runstop_and_charsetswitch + jsr cbm.CLRCHN ; reset i/o channels + jsr sys.enable_runstop_and_charsetswitch ldx prog8_lib.orig_stackpointer txs rts ; return to original caller diff --git a/compiler/res/prog8lib/c128/textio.p8 b/compiler/res/prog8lib/c128/textio.p8 index be645ddfd..f77e55621 100644 --- a/compiler/res/prog8lib/c128/textio.p8 +++ b/compiler/res/prog8lib/c128/textio.p8 @@ -30,10 +30,10 @@ asmsub column(ubyte col @A) clobbers(A, X, Y) { ; ---- set the cursor on the given column (starting with 0) on the current line %asm {{ sec - jsr c64.PLOT + jsr cbm.PLOT tay clc - jmp c64.PLOT + jmp cbm.PLOT }} } @@ -57,10 +57,10 @@ asmsub clear_screenchars (ubyte char @ A) clobbers(Y) { ; (assumes screen matrix is at the default address) %asm {{ ldy #250 -- sta c64.Screen+250*0-1,y - sta c64.Screen+250*1-1,y - sta c64.Screen+250*2-1,y - sta c64.Screen+250*3-1,y +- sta cbm.Screen+250*0-1,y + sta cbm.Screen+250*1-1,y + sta cbm.Screen+250*2-1,y + sta cbm.Screen+250*3-1,y dey bne - rts @@ -72,10 +72,10 @@ asmsub clear_screencolors (ubyte color @ A) clobbers(Y) { ; (assumes color matrix is at the default address) %asm {{ ldy #250 -- sta c64.Colors+250*0-1,y - sta c64.Colors+250*1-1,y - sta c64.Colors+250*2-1,y - sta c64.Colors+250*3-1,y +- sta cbm.Colors+250*0-1,y + sta cbm.Colors+250*1-1,y + sta cbm.Colors+250*2-1,y + sta cbm.Colors+250*3-1,y dey bne - rts @@ -83,7 +83,7 @@ asmsub clear_screencolors (ubyte color @ A) clobbers(Y) { } sub color (ubyte txtcol) { - c64.COLOR = txtcol + cbm.COLOR = txtcol } sub lowercase() { @@ -110,10 +110,10 @@ asmsub scroll_left (ubyte alsocolors @ Pc) clobbers(A, Y) { ldy #38 - .for row=0, row<=24, row+=1 - lda c64.Screen + 40*row + 1,x - sta c64.Screen + 40*row + 0,x - lda c64.Colors + 40*row + 1,x - sta c64.Colors + 40*row + 0,x + lda cbm.Screen + 40*row + 1,x + sta cbm.Screen + 40*row + 0,x + lda cbm.Colors + 40*row + 1,x + sta cbm.Colors + 40*row + 0,x .next inx dey @@ -125,8 +125,8 @@ _scroll_screen ; scroll only the screen memory ldy #38 - .for row=0, row<=24, row+=1 - lda c64.Screen + 40*row + 1,x - sta c64.Screen + 40*row + 0,x + lda cbm.Screen + 40*row + 1,x + sta cbm.Screen + 40*row + 0,x .next inx dey @@ -149,10 +149,10 @@ asmsub scroll_right (ubyte alsocolors @ Pc) clobbers(A) { ldx #38 - .for row=0, row<=24, row+=1 - lda c64.Screen + 40*row + 0,x - sta c64.Screen + 40*row + 1,x - lda c64.Colors + 40*row + 0,x - sta c64.Colors + 40*row + 1,x + lda cbm.Screen + 40*row + 0,x + sta cbm.Screen + 40*row + 1,x + lda cbm.Colors + 40*row + 0,x + sta cbm.Colors + 40*row + 1,x .next dex bpl - @@ -162,8 +162,8 @@ _scroll_screen ; scroll only the screen memory ldx #38 - .for row=0, row<=24, row+=1 - lda c64.Screen + 40*row + 0,x - sta c64.Screen + 40*row + 1,x + lda cbm.Screen + 40*row + 0,x + sta cbm.Screen + 40*row + 1,x .next dex bpl - @@ -185,10 +185,10 @@ asmsub scroll_up (ubyte alsocolors @ Pc) clobbers(A) { ldx #39 - .for row=1, row<=24, row+=1 - lda c64.Screen + 40*row,x - sta c64.Screen + 40*(row-1),x - lda c64.Colors + 40*row,x - sta c64.Colors + 40*(row-1),x + lda cbm.Screen + 40*row,x + sta cbm.Screen + 40*(row-1),x + lda cbm.Colors + 40*row,x + sta cbm.Colors + 40*(row-1),x .next dex bpl - @@ -198,8 +198,8 @@ _scroll_screen ; scroll only the screen memory ldx #39 - .for row=1, row<=24, row+=1 - lda c64.Screen + 40*row,x - sta c64.Screen + 40*(row-1),x + lda cbm.Screen + 40*row,x + sta cbm.Screen + 40*(row-1),x .next dex bpl - @@ -221,10 +221,10 @@ asmsub scroll_down (ubyte alsocolors @ Pc) clobbers(A) { ldx #39 - .for row=23, row>=0, row-=1 - lda c64.Colors + 40*row,x - sta c64.Colors + 40*(row+1),x - lda c64.Screen + 40*row,x - sta c64.Screen + 40*(row+1),x + lda cbm.Colors + 40*row,x + sta cbm.Colors + 40*(row+1),x + lda cbm.Screen + 40*row,x + sta cbm.Screen + 40*(row+1),x .next dex bpl - @@ -234,8 +234,8 @@ _scroll_screen ; scroll only the screen memory ldx #39 - .for row=23, row>=0, row-=1 - lda c64.Screen + 40*row,x - sta c64.Screen + 40*(row+1),x + lda cbm.Screen + 40*row,x + sta cbm.Screen + 40*(row+1),x .next dex bpl - @@ -245,20 +245,20 @@ _scroll_screen ; scroll only the screen memory }} } -romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use c64.CHROUT directly ofcourse. +romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use cbm.CHROUT directly ofcourse. asmsub print (str text @ AY) clobbers(A,Y) { ; ---- print null terminated string from A/Y ; note: the compiler contains an optimization that will replace ; a call to this subroutine with a string argument of just one char, - ; by just one call to c64.CHROUT of that single char. + ; by just one call to cbm.CHROUT of that single char. %asm {{ sta P8ZP_SCRATCH_B1 sty P8ZP_SCRATCH_REG ldy #0 - lda (P8ZP_SCRATCH_B1),y beq + - jsr c64.CHROUT + jsr cbm.CHROUT iny bne - + rts @@ -272,11 +272,11 @@ asmsub print_ub0 (ubyte value @ A) clobbers(A,Y) { jsr conv.ubyte2decimal pha tya - jsr c64.CHROUT + jsr cbm.CHROUT pla - jsr c64.CHROUT + jsr cbm.CHROUT txa - jsr c64.CHROUT + jsr cbm.CHROUT ldx P8ZP_SCRATCH_REG rts }} @@ -292,16 +292,16 @@ _print_byte_digits cpy #'0' beq + tya - jsr c64.CHROUT + jsr cbm.CHROUT pla - jsr c64.CHROUT + jsr cbm.CHROUT jmp _ones + pla cmp #'0' beq _ones - jsr c64.CHROUT + jsr cbm.CHROUT _ones txa - jsr c64.CHROUT + jsr cbm.CHROUT ldx P8ZP_SCRATCH_REG rts }} @@ -315,7 +315,7 @@ asmsub print_b (byte value @ A) clobbers(A,Y) { cmp #0 bpl + lda #'-' - jsr c64.CHROUT + jsr cbm.CHROUT + pla jsr conv.byte2decimal jmp print_ub._print_byte_digits @@ -329,12 +329,12 @@ asmsub print_ubhex (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) { bcc + pha lda #'$' - jsr c64.CHROUT + jsr cbm.CHROUT pla + jsr conv.ubyte2hex - jsr c64.CHROUT + jsr cbm.CHROUT tya - jsr c64.CHROUT + jsr cbm.CHROUT ldx P8ZP_SCRATCH_REG rts }} @@ -347,13 +347,13 @@ asmsub print_ubbin (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) { sta P8ZP_SCRATCH_B1 bcc + lda #'%' - jsr c64.CHROUT + jsr cbm.CHROUT + ldy #8 - lda #'0' asl P8ZP_SCRATCH_B1 bcc + lda #'1' -+ jsr c64.CHROUT ++ jsr cbm.CHROUT dey bne - ldx P8ZP_SCRATCH_REG @@ -394,7 +394,7 @@ asmsub print_uw0 (uword value @ AY) clobbers(A,Y) { ldy #0 - lda conv.uword2decimal.decTenThousands,y beq + - jsr c64.CHROUT + jsr cbm.CHROUT iny bne - + ldx P8ZP_SCRATCH_REG @@ -417,14 +417,14 @@ asmsub print_uw (uword value @ AY) clobbers(A,Y) { bne - _gotdigit - jsr c64.CHROUT + jsr cbm.CHROUT iny lda conv.uword2decimal.decTenThousands,y bne _gotdigit rts _allzero lda #'0' - jmp c64.CHROUT + jmp cbm.CHROUT }} } @@ -435,7 +435,7 @@ asmsub print_w (word value @ AY) clobbers(A,Y) { bpl + pha lda #'-' - jsr c64.CHROUT + jsr cbm.CHROUT tya eor #255 tay @@ -457,7 +457,7 @@ asmsub input_chars (uword buffer @ AY) clobbers(A) -> ubyte @ Y { sta P8ZP_SCRATCH_W1 sty P8ZP_SCRATCH_W1+1 ldy #0 ; char counter = 0 -- jsr c64.CHRIN +- jsr cbm.CHRIN cmp #$0d ; return (ascii 13) pressed? beq + ; yes, end. sta (P8ZP_SCRATCH_W1),y ; else store char in buffer @@ -588,7 +588,7 @@ asmsub plot (ubyte col @ Y, ubyte row @ A) clobbers(A) { stx P8ZP_SCRATCH_REG tax clc - jsr c64.PLOT + jsr cbm.PLOT ldx P8ZP_SCRATCH_REG rts }} @@ -597,7 +597,7 @@ asmsub plot (ubyte col @ Y, ubyte row @ A) clobbers(A) { asmsub width() clobbers(X,Y) -> ubyte @A { ; -- returns the text screen width (number of columns) %asm {{ - jsr c64.SCREEN + jsr cbm.SCREEN txa rts }} @@ -606,7 +606,7 @@ asmsub width() clobbers(X,Y) -> ubyte @A { asmsub height() clobbers(X, Y) -> ubyte @A { ; -- returns the text screen height (number of rows) %asm {{ - jsr c64.SCREEN + jsr cbm.SCREEN tya rts }} diff --git a/compiler/res/prog8lib/c64/syslib.p8 b/compiler/res/prog8lib/c64/syslib.p8 index d33634e18..b444f26cf 100644 --- a/compiler/res/prog8lib/c64/syslib.p8 +++ b/compiler/res/prog8lib/c64/syslib.p8 @@ -1,7 +1,11 @@ ; Prog8 definitions for the Commodore-64 ; Including memory registers, I/O registers, Basic and Kernal subroutines. -c64 { + +cbm { + + ; Commodore (CBM) common variables, vectors and kernal routines + &ubyte TIME_HI = $a0 ; software jiffy clock, hi byte &ubyte TIME_MID = $a1 ; .. mid byte &ubyte TIME_LO = $a2 ; .. lo byte. Updated by IRQ every 1/60 sec @@ -50,6 +54,91 @@ c64 { const uword Screen = $0400 ; to have this as an array[40*25] the compiler would have to support array size > 255 const uword Colors = $d800 ; to have this as an array[40*25] the compiler would have to support array size > 255 + +; ---- CBM ROM kernal routines (C64 addresses) ---- + +romsub $AB1E = STROUT(uword strptr @ AY) clobbers(A, X, Y) ; print null-terminated string (use txt.print instead) +romsub $E544 = CLEARSCR() clobbers(A,X,Y) ; clear the screen +romsub $E566 = HOMECRSR() clobbers(A,X,Y) ; cursor to top left of screen +romsub $EA31 = IRQDFRT() clobbers(A,X,Y) ; default IRQ routine +romsub $EA81 = IRQDFEND() clobbers(A,X,Y) ; default IRQ end/cleanup +romsub $FF81 = CINT() clobbers(A,X,Y) ; (alias: SCINIT) initialize screen editor and video chip +romsub $FF84 = IOINIT() clobbers(A, X) ; initialize I/O devices (CIA, SID, IRQ) +romsub $FF87 = RAMTAS() clobbers(A,X,Y) ; initialize RAM, tape buffer, screen +romsub $FF8A = RESTOR() clobbers(A,X,Y) ; restore default I/O vectors +romsub $FF8D = VECTOR(uword userptr @ XY, ubyte dir @ Pc) clobbers(A,Y) ; read/set I/O vector table +romsub $FF90 = SETMSG(ubyte value @ A) ; set Kernal message control flag +romsub $FF93 = SECOND(ubyte address @ A) clobbers(A) ; (alias: LSTNSA) send secondary address after LISTEN +romsub $FF96 = TKSA(ubyte address @ A) clobbers(A) ; (alias: TALKSA) send secondary address after TALK +romsub $FF99 = MEMTOP(uword address @ XY, ubyte dir @ Pc) -> uword @ XY ; read/set top of memory pointer +romsub $FF9C = MEMBOT(uword address @ XY, ubyte dir @ Pc) -> uword @ XY ; read/set bottom of memory pointer +romsub $FF9F = SCNKEY() clobbers(A,X,Y) ; scan the keyboard +romsub $FFA2 = SETTMO(ubyte timeout @ A) ; set time-out flag for IEEE bus +romsub $FFA5 = ACPTR() -> ubyte @ A ; (alias: IECIN) input byte from serial bus +romsub $FFA8 = CIOUT(ubyte databyte @ A) ; (alias: IECOUT) output byte to serial bus +romsub $FFAB = UNTLK() clobbers(A) ; command serial bus device to UNTALK +romsub $FFAE = UNLSN() clobbers(A) ; command serial bus device to UNLISTEN +romsub $FFB1 = LISTEN(ubyte device @ A) clobbers(A) ; command serial bus device to LISTEN +romsub $FFB4 = TALK(ubyte device @ A) clobbers(A) ; command serial bus device to TALK +romsub $FFB7 = READST() -> ubyte @ A ; read I/O status word +romsub $FFBA = SETLFS(ubyte logical @ A, ubyte device @ X, ubyte secondary @ Y) ; set logical file parameters +romsub $FFBD = SETNAM(ubyte namelen @ A, str filename @ XY) ; set filename parameters +romsub $FFC0 = OPEN() clobbers(X,Y) -> ubyte @Pc, ubyte @A ; (via 794 ($31A)) open a logical file +romsub $FFC3 = CLOSE(ubyte logical @ A) clobbers(A,X,Y) ; (via 796 ($31C)) close a logical file +romsub $FFC6 = CHKIN(ubyte logical @ X) clobbers(A,X) -> ubyte @Pc ; (via 798 ($31E)) define an input channel +romsub $FFC9 = CHKOUT(ubyte logical @ X) clobbers(A,X) ; (via 800 ($320)) define an output channel +romsub $FFCC = CLRCHN() clobbers(A,X) ; (via 802 ($322)) restore default devices +romsub $FFCF = CHRIN() clobbers(X, Y) -> ubyte @ A ; (via 804 ($324)) input a character (for keyboard, read a whole line from the screen) A=byte read. +romsub $FFD2 = CHROUT(ubyte char @ A) ; (via 806 ($326)) output a character +romsub $FFD5 = LOAD(ubyte verify @ A, uword address @ XY) -> ubyte @Pc, ubyte @ A, uword @ XY ; (via 816 ($330)) load from device +romsub $FFD8 = SAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) -> ubyte @ Pc, ubyte @ A ; (via 818 ($332)) save to a device +romsub $FFDB = SETTIM(ubyte low @ A, ubyte middle @ X, ubyte high @ Y) ; set the software clock +romsub $FFDE = RDTIM() -> ubyte @ A, ubyte @ X, ubyte @ Y ; read the software clock (A=lo,X=mid,Y=high) +romsub $FFE1 = STOP() clobbers(X) -> ubyte @ Pz, ubyte @ A ; (via 808 ($328)) check the STOP key (and some others in A) +romsub $FFE4 = GETIN() clobbers(X,Y) -> ubyte @Pc, ubyte @ A ; (via 810 ($32A)) get a character +romsub $FFE7 = CLALL() clobbers(A,X) ; (via 812 ($32C)) close all files +romsub $FFEA = UDTIM() clobbers(A,X) ; update the software clock +romsub $FFED = SCREEN() -> ubyte @ X, ubyte @ Y ; read number of screen rows and columns +romsub $FFF0 = PLOT(ubyte col @ Y, ubyte row @ X, ubyte dir @ Pc) -> ubyte @ X, ubyte @ Y ; read/set position of cursor on screen. Use txt.plot for a 'safe' wrapper that preserves X. +romsub $FFF3 = IOBASE() -> uword @ XY ; read base address of I/O devices + +asmsub STOP2() -> ubyte @A { + ; -- check if STOP key was pressed, returns true if so. More convenient to use than STOP() because that only sets the carry status flag. + %asm {{ + txa + pha + jsr cbm.STOP + beq + + pla + tax + lda #0 + rts ++ pla + tax + lda #1 + rts + }} +} + +asmsub RDTIM16() -> uword @AY { + ; -- like RDTIM() but only returning the lower 16 bits in AY for convenience + %asm {{ + stx P8ZP_SCRATCH_REG + jsr cbm.RDTIM + pha + txa + tay + pla + ldx P8ZP_SCRATCH_REG + rts + }} +} + +} + +c64 { + ; C64 I/O registers (VIC, SID, CIA) + ; the default locations of the 8 sprite pointers (store address of sprite / 64) &ubyte SPRPTR0 = 2040 &ubyte SPRPTR1 = 2041 @@ -199,94 +288,14 @@ c64 { ; ---- end of SID registers ---- - -; ---- C64 ROM kernal routines ---- - -romsub $AB1E = STROUT(uword strptr @ AY) clobbers(A, X, Y) ; print null-terminated string (use txt.print instead) -romsub $E544 = CLEARSCR() clobbers(A,X,Y) ; clear the screen -romsub $E566 = HOMECRSR() clobbers(A,X,Y) ; cursor to top left of screen -romsub $EA31 = IRQDFRT() clobbers(A,X,Y) ; default IRQ routine -romsub $EA81 = IRQDFEND() clobbers(A,X,Y) ; default IRQ end/cleanup -romsub $FF81 = CINT() clobbers(A,X,Y) ; (alias: SCINIT) initialize screen editor and video chip -romsub $FF84 = IOINIT() clobbers(A, X) ; initialize I/O devices (CIA, SID, IRQ) -romsub $FF87 = RAMTAS() clobbers(A,X,Y) ; initialize RAM, tape buffer, screen -romsub $FF8A = RESTOR() clobbers(A,X,Y) ; restore default I/O vectors -romsub $FF8D = VECTOR(uword userptr @ XY, ubyte dir @ Pc) clobbers(A,Y) ; read/set I/O vector table -romsub $FF90 = SETMSG(ubyte value @ A) ; set Kernal message control flag -romsub $FF93 = SECOND(ubyte address @ A) clobbers(A) ; (alias: LSTNSA) send secondary address after LISTEN -romsub $FF96 = TKSA(ubyte address @ A) clobbers(A) ; (alias: TALKSA) send secondary address after TALK -romsub $FF99 = MEMTOP(uword address @ XY, ubyte dir @ Pc) -> uword @ XY ; read/set top of memory pointer -romsub $FF9C = MEMBOT(uword address @ XY, ubyte dir @ Pc) -> uword @ XY ; read/set bottom of memory pointer -romsub $FF9F = SCNKEY() clobbers(A,X,Y) ; scan the keyboard -romsub $FFA2 = SETTMO(ubyte timeout @ A) ; set time-out flag for IEEE bus -romsub $FFA5 = ACPTR() -> ubyte @ A ; (alias: IECIN) input byte from serial bus -romsub $FFA8 = CIOUT(ubyte databyte @ A) ; (alias: IECOUT) output byte to serial bus -romsub $FFAB = UNTLK() clobbers(A) ; command serial bus device to UNTALK -romsub $FFAE = UNLSN() clobbers(A) ; command serial bus device to UNLISTEN -romsub $FFB1 = LISTEN(ubyte device @ A) clobbers(A) ; command serial bus device to LISTEN -romsub $FFB4 = TALK(ubyte device @ A) clobbers(A) ; command serial bus device to TALK -romsub $FFB7 = READST() -> ubyte @ A ; read I/O status word -romsub $FFBA = SETLFS(ubyte logical @ A, ubyte device @ X, ubyte secondary @ Y) ; set logical file parameters -romsub $FFBD = SETNAM(ubyte namelen @ A, str filename @ XY) ; set filename parameters -romsub $FFC0 = OPEN() clobbers(X,Y) -> ubyte @Pc, ubyte @A ; (via 794 ($31A)) open a logical file -romsub $FFC3 = CLOSE(ubyte logical @ A) clobbers(A,X,Y) ; (via 796 ($31C)) close a logical file -romsub $FFC6 = CHKIN(ubyte logical @ X) clobbers(A,X) -> ubyte @Pc ; (via 798 ($31E)) define an input channel -romsub $FFC9 = CHKOUT(ubyte logical @ X) clobbers(A,X) ; (via 800 ($320)) define an output channel -romsub $FFCC = CLRCHN() clobbers(A,X) ; (via 802 ($322)) restore default devices -romsub $FFCF = CHRIN() clobbers(X, Y) -> ubyte @ A ; (via 804 ($324)) input a character (for keyboard, read a whole line from the screen) A=byte read. -romsub $FFD2 = CHROUT(ubyte char @ A) ; (via 806 ($326)) output a character -romsub $FFD5 = LOAD(ubyte verify @ A, uword address @ XY) -> ubyte @Pc, ubyte @ A, uword @ XY ; (via 816 ($330)) load from device -romsub $FFD8 = SAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) -> ubyte @ Pc, ubyte @ A ; (via 818 ($332)) save to a device -romsub $FFDB = SETTIM(ubyte low @ A, ubyte middle @ X, ubyte high @ Y) ; set the software clock -romsub $FFDE = RDTIM() -> ubyte @ A, ubyte @ X, ubyte @ Y ; read the software clock (A=lo,X=mid,Y=high) -romsub $FFE1 = STOP() clobbers(X) -> ubyte @ Pz, ubyte @ A ; (via 808 ($328)) check the STOP key (and some others in A) -romsub $FFE4 = GETIN() clobbers(X,Y) -> ubyte @Pc, ubyte @ A ; (via 810 ($32A)) get a character -romsub $FFE7 = CLALL() clobbers(A,X) ; (via 812 ($32C)) close all files -romsub $FFEA = UDTIM() clobbers(A,X) ; update the software clock -romsub $FFED = SCREEN() -> ubyte @ X, ubyte @ Y ; read number of screen rows and columns -romsub $FFF0 = PLOT(ubyte col @ Y, ubyte row @ X, ubyte dir @ Pc) -> ubyte @ X, ubyte @ Y ; read/set position of cursor on screen. Use txt.plot for a 'safe' wrapper that preserves X. -romsub $FFF3 = IOBASE() -> uword @ XY ; read base address of I/O devices - -; ---- end of C64 ROM kernal routines ---- - -; ---- utilities ----- - -asmsub STOP2() -> ubyte @A { - ; -- check if STOP key was pressed, returns true if so. More convenient to use than STOP() because that only sets the carry status flag. - %asm {{ - txa - pha - jsr c64.STOP - beq + - pla - tax - lda #0 - rts -+ pla - tax - lda #1 - rts - }} } -asmsub RDTIM16() -> uword @AY { - ; -- like RDTIM() but only returning the lower 16 bits in AY for convenience - %asm {{ - stx P8ZP_SCRATCH_REG - jsr c64.RDTIM - pha - txa - tay - pla - ldx P8ZP_SCRATCH_REG - rts - }} -} +sys { + ; ------- lowlevel system routines -------- + const ubyte target = 64 ; compilation target specifier. 64 = C64, 128 = C128, 16 = CommanderX16. -; ---- C64 specific system utility routines: ---- - asmsub init_system() { ; Initializes the machine to a sane starting state. ; Called automatically by the loader program logic. @@ -301,13 +310,13 @@ asmsub init_system() { sta $00 lda #%00100111 sta $01 - jsr c64.IOINIT - jsr c64.RESTOR - jsr c64.CINT + jsr cbm.IOINIT + jsr cbm.RESTOR + jsr cbm.CINT lda #6 sta c64.EXTCOL lda #7 - sta c64.COLOR + sta cbm.COLOR lda #0 sta c64.BGCOL0 jsr disable_runstop_and_charsetswitch @@ -327,7 +336,7 @@ asmsub init_system_phase2() { asmsub cleanup_at_exit() { ; executed when the main subroutine does rts %asm {{ - jmp c64.enable_runstop_and_charsetswitch + jmp sys.enable_runstop_and_charsetswitch }} } @@ -360,9 +369,9 @@ asmsub set_irq(uword handler @AY, ubyte useKernal @Pc) clobbers(A) { sta _use_kernal sei lda #<_irq_handler - sta c64.CINV + sta cbm.CINV lda #>_irq_handler - sta c64.CINV+1 + sta cbm.CINV+1 cli rts _irq_handler jsr _irq_handler_init @@ -380,7 +389,7 @@ _modified jsr $ffff ; modified tax pla rti -+ jmp c64.IRQDFRT ; continue with normal kernal irq routine ++ jmp cbm.IRQDFRT ; continue with normal kernal irq routine _use_kernal .byte 0 @@ -432,10 +441,10 @@ IRQ_SCRATCH_ZPWORD2 .word 0 asmsub restore_irq() clobbers(A) { %asm {{ sei - lda #c64.IRQDFRT - sta c64.CINV+1 + lda #cbm.IRQDFRT + sta cbm.CINV+1 lda #0 sta c64.IREQMASK ; disable raster irq lda #%10000001 @@ -447,19 +456,19 @@ asmsub restore_irq() clobbers(A) { asmsub set_rasterirq(uword handler @AY, uword rasterpos @R0, ubyte useKernal @Pc) clobbers(A) { %asm {{ - sta _modified+1 - sty _modified+2 - lda #0 - adc #0 - sta set_irq._use_kernal + sta _modified+1 + sty _modified+2 + lda #0 + adc #0 + sta set_irq._use_kernal lda cx16.r0 ldy cx16.r0+1 sei jsr _setup_raster_irq lda #<_raster_irq_handler - sta c64.CINV + sta cbm.CINV lda #>_raster_irq_handler - sta c64.CINV+1 + sta cbm.CINV+1 cli rts @@ -467,8 +476,8 @@ _raster_irq_handler jsr set_irq._irq_handler_init _modified jsr $ffff ; modified jsr set_irq._irq_handler_end - lda #$ff - sta c64.VICIRQ ; acknowledge raster irq + lda #$ff + sta c64.VICIRQ ; acknowledge raster irq lda set_irq._use_kernal bne + ; end irq processing - don't use kernal's irq handling @@ -478,7 +487,7 @@ _modified jsr $ffff ; modified tax pla rti -+ jmp c64.IRQDFRT ; continue with kernal irq routine ++ jmp cbm.IRQDFRT ; continue with kernal irq routine _setup_raster_irq pha @@ -502,23 +511,14 @@ _setup_raster_irq }} } -; ---- end of C64 specific system utility routines ---- -} - -sys { - ; ------- lowlevel system routines -------- - - const ubyte target = 64 ; compilation target specifier. 64 = C64, 128 = C128, 16 = CommanderX16. - - - asmsub reset_system() { + asmsub reset_system() { ; Soft-reset the system back to initial power-on Basic prompt. %asm {{ sei lda #14 sta $01 ; bank the kernal in - jmp (c64.RESET_VEC) + jmp (cbm.RESET_VEC) }} } @@ -536,9 +536,9 @@ _loop lda P8ZP_SCRATCH_W1 ldx P8ZP_SCRATCH_B1 rts -+ lda c64.TIME_LO ++ lda cbm.TIME_LO sta P8ZP_SCRATCH_B1 -- lda c64.TIME_LO +- lda cbm.TIME_LO cmp P8ZP_SCRATCH_B1 beq - @@ -700,8 +700,8 @@ _longcopy %asm {{ lda #31 sta $01 ; bank the kernal in - jsr c64.CLRCHN ; reset i/o channels - jsr c64.enable_runstop_and_charsetswitch + jsr cbm.CLRCHN ; reset i/o channels + jsr sys.enable_runstop_and_charsetswitch ldx prog8_lib.orig_stackpointer txs rts ; return to original caller diff --git a/compiler/res/prog8lib/c64/textio.p8 b/compiler/res/prog8lib/c64/textio.p8 index f59df6b07..25b1b81c5 100644 --- a/compiler/res/prog8lib/c64/textio.p8 +++ b/compiler/res/prog8lib/c64/textio.p8 @@ -30,10 +30,10 @@ asmsub column(ubyte col @A) clobbers(A, X, Y) { ; ---- set the cursor on the given column (starting with 0) on the current line %asm {{ sec - jsr c64.PLOT + jsr cbm.PLOT tay clc - jmp c64.PLOT + jmp cbm.PLOT }} } @@ -57,10 +57,10 @@ asmsub clear_screenchars (ubyte char @ A) clobbers(Y) { ; (assumes screen matrix is at the default address) %asm {{ ldy #250 -- sta c64.Screen+250*0-1,y - sta c64.Screen+250*1-1,y - sta c64.Screen+250*2-1,y - sta c64.Screen+250*3-1,y +- sta cbm.Screen+250*0-1,y + sta cbm.Screen+250*1-1,y + sta cbm.Screen+250*2-1,y + sta cbm.Screen+250*3-1,y dey bne - rts @@ -72,10 +72,10 @@ asmsub clear_screencolors (ubyte color @ A) clobbers(Y) { ; (assumes color matrix is at the default address) %asm {{ ldy #250 -- sta c64.Colors+250*0-1,y - sta c64.Colors+250*1-1,y - sta c64.Colors+250*2-1,y - sta c64.Colors+250*3-1,y +- sta cbm.Colors+250*0-1,y + sta cbm.Colors+250*1-1,y + sta cbm.Colors+250*2-1,y + sta cbm.Colors+250*3-1,y dey bne - rts @@ -83,7 +83,7 @@ asmsub clear_screencolors (ubyte color @ A) clobbers(Y) { } sub color (ubyte txtcol) { - c64.COLOR = txtcol + cbm.COLOR = txtcol } sub lowercase() { @@ -108,10 +108,10 @@ asmsub scroll_left (ubyte alsocolors @ Pc) clobbers(A, Y) { ldy #38 - .for row=0, row<=24, row+=1 - lda c64.Screen + 40*row + 1,x - sta c64.Screen + 40*row + 0,x - lda c64.Colors + 40*row + 1,x - sta c64.Colors + 40*row + 0,x + lda cbm.Screen + 40*row + 1,x + sta cbm.Screen + 40*row + 0,x + lda cbm.Colors + 40*row + 1,x + sta cbm.Colors + 40*row + 0,x .next inx dey @@ -123,8 +123,8 @@ _scroll_screen ; scroll only the screen memory ldy #38 - .for row=0, row<=24, row+=1 - lda c64.Screen + 40*row + 1,x - sta c64.Screen + 40*row + 0,x + lda cbm.Screen + 40*row + 1,x + sta cbm.Screen + 40*row + 0,x .next inx dey @@ -147,10 +147,10 @@ asmsub scroll_right (ubyte alsocolors @ Pc) clobbers(A) { ldx #38 - .for row=0, row<=24, row+=1 - lda c64.Screen + 40*row + 0,x - sta c64.Screen + 40*row + 1,x - lda c64.Colors + 40*row + 0,x - sta c64.Colors + 40*row + 1,x + lda cbm.Screen + 40*row + 0,x + sta cbm.Screen + 40*row + 1,x + lda cbm.Colors + 40*row + 0,x + sta cbm.Colors + 40*row + 1,x .next dex bpl - @@ -160,8 +160,8 @@ _scroll_screen ; scroll only the screen memory ldx #38 - .for row=0, row<=24, row+=1 - lda c64.Screen + 40*row + 0,x - sta c64.Screen + 40*row + 1,x + lda cbm.Screen + 40*row + 0,x + sta cbm.Screen + 40*row + 1,x .next dex bpl - @@ -183,10 +183,10 @@ asmsub scroll_up (ubyte alsocolors @ Pc) clobbers(A) { ldx #39 - .for row=1, row<=24, row+=1 - lda c64.Screen + 40*row,x - sta c64.Screen + 40*(row-1),x - lda c64.Colors + 40*row,x - sta c64.Colors + 40*(row-1),x + lda cbm.Screen + 40*row,x + sta cbm.Screen + 40*(row-1),x + lda cbm.Colors + 40*row,x + sta cbm.Colors + 40*(row-1),x .next dex bpl - @@ -196,8 +196,8 @@ _scroll_screen ; scroll only the screen memory ldx #39 - .for row=1, row<=24, row+=1 - lda c64.Screen + 40*row,x - sta c64.Screen + 40*(row-1),x + lda cbm.Screen + 40*row,x + sta cbm.Screen + 40*(row-1),x .next dex bpl - @@ -219,10 +219,10 @@ asmsub scroll_down (ubyte alsocolors @ Pc) clobbers(A) { ldx #39 - .for row=23, row>=0, row-=1 - lda c64.Colors + 40*row,x - sta c64.Colors + 40*(row+1),x - lda c64.Screen + 40*row,x - sta c64.Screen + 40*(row+1),x + lda cbm.Colors + 40*row,x + sta cbm.Colors + 40*(row+1),x + lda cbm.Screen + 40*row,x + sta cbm.Screen + 40*(row+1),x .next dex bpl - @@ -232,8 +232,8 @@ _scroll_screen ; scroll only the screen memory ldx #39 - .for row=23, row>=0, row-=1 - lda c64.Screen + 40*row,x - sta c64.Screen + 40*(row+1),x + lda cbm.Screen + 40*row,x + sta cbm.Screen + 40*(row+1),x .next dex bpl - @@ -243,20 +243,20 @@ _scroll_screen ; scroll only the screen memory }} } -romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use c64.CHROUT directly ofcourse. +romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use cbm.CHROUT directly ofcourse. asmsub print (str text @ AY) clobbers(A,Y) { ; ---- print null terminated string from A/Y ; note: the compiler contains an optimization that will replace ; a call to this subroutine with a string argument of just one char, - ; by just one call to c64.CHROUT of that single char. + ; by just one call to cbm.CHROUT of that single char. %asm {{ sta P8ZP_SCRATCH_B1 sty P8ZP_SCRATCH_REG ldy #0 - lda (P8ZP_SCRATCH_B1),y beq + - jsr c64.CHROUT + jsr cbm.CHROUT iny bne - + rts @@ -270,11 +270,11 @@ asmsub print_ub0 (ubyte value @ A) clobbers(A,Y) { jsr conv.ubyte2decimal pha tya - jsr c64.CHROUT + jsr cbm.CHROUT pla - jsr c64.CHROUT + jsr cbm.CHROUT txa - jsr c64.CHROUT + jsr cbm.CHROUT ldx P8ZP_SCRATCH_REG rts }} @@ -290,16 +290,16 @@ _print_byte_digits cpy #'0' beq + tya - jsr c64.CHROUT + jsr cbm.CHROUT pla - jsr c64.CHROUT + jsr cbm.CHROUT jmp _ones + pla cmp #'0' beq _ones - jsr c64.CHROUT + jsr cbm.CHROUT _ones txa - jsr c64.CHROUT + jsr cbm.CHROUT ldx P8ZP_SCRATCH_REG rts }} @@ -313,7 +313,7 @@ asmsub print_b (byte value @ A) clobbers(A,Y) { cmp #0 bpl + lda #'-' - jsr c64.CHROUT + jsr cbm.CHROUT + pla jsr conv.byte2decimal jmp print_ub._print_byte_digits @@ -327,12 +327,12 @@ asmsub print_ubhex (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) { bcc + pha lda #'$' - jsr c64.CHROUT + jsr cbm.CHROUT pla + jsr conv.ubyte2hex - jsr c64.CHROUT + jsr cbm.CHROUT tya - jsr c64.CHROUT + jsr cbm.CHROUT ldx P8ZP_SCRATCH_REG rts }} @@ -345,13 +345,13 @@ asmsub print_ubbin (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) { sta P8ZP_SCRATCH_B1 bcc + lda #'%' - jsr c64.CHROUT + jsr cbm.CHROUT + ldy #8 - lda #'0' asl P8ZP_SCRATCH_B1 bcc + lda #'1' -+ jsr c64.CHROUT ++ jsr cbm.CHROUT dey bne - ldx P8ZP_SCRATCH_REG @@ -392,7 +392,7 @@ asmsub print_uw0 (uword value @ AY) clobbers(A,Y) { ldy #0 - lda conv.uword2decimal.decTenThousands,y beq + - jsr c64.CHROUT + jsr cbm.CHROUT iny bne - + ldx P8ZP_SCRATCH_REG @@ -415,14 +415,14 @@ asmsub print_uw (uword value @ AY) clobbers(A,Y) { bne - _gotdigit - jsr c64.CHROUT + jsr cbm.CHROUT iny lda conv.uword2decimal.decTenThousands,y bne _gotdigit rts _allzero lda #'0' - jmp c64.CHROUT + jmp cbm.CHROUT }} } @@ -433,7 +433,7 @@ asmsub print_w (word value @ AY) clobbers(A,Y) { bpl + pha lda #'-' - jsr c64.CHROUT + jsr cbm.CHROUT tya eor #255 tay @@ -455,7 +455,7 @@ asmsub input_chars (uword buffer @ AY) clobbers(A) -> ubyte @ Y { sta P8ZP_SCRATCH_W1 sty P8ZP_SCRATCH_W1+1 ldy #0 ; char counter = 0 -- jsr c64.CHRIN +- jsr cbm.CHRIN cmp #$0d ; return (ascii 13) pressed? beq + ; yes, end. sta (P8ZP_SCRATCH_W1),y ; else store char in buffer @@ -586,7 +586,7 @@ asmsub plot (ubyte col @ Y, ubyte row @ A) clobbers(A) { stx P8ZP_SCRATCH_REG tax clc - jsr c64.PLOT + jsr cbm.PLOT ldx P8ZP_SCRATCH_REG rts }} @@ -595,7 +595,7 @@ asmsub plot (ubyte col @ Y, ubyte row @ A) clobbers(A) { asmsub width() clobbers(X,Y) -> ubyte @A { ; -- returns the text screen width (number of columns) %asm {{ - jsr c64.SCREEN + jsr cbm.SCREEN txa rts }} @@ -604,7 +604,7 @@ asmsub width() clobbers(X,Y) -> ubyte @A { asmsub height() clobbers(X, Y) -> ubyte @A { ; -- returns the text screen height (number of rows) %asm {{ - jsr c64.SCREEN + jsr cbm.SCREEN tya rts }} diff --git a/compiler/res/prog8lib/cx16/cx16diskio.p8 b/compiler/res/prog8lib/cx16/cx16diskio.p8 index e0e738764..8bb6e6a00 100644 --- a/compiler/res/prog8lib/cx16/cx16diskio.p8 +++ b/compiler/res/prog8lib/cx16/cx16diskio.p8 @@ -53,26 +53,26 @@ internal_vload: bne ++ + ldy #0 ; normal load mode + lda #1 - jsr c64.SETLFS + jsr cbm.SETLFS lda cx16.r0 ldy cx16.r0+1 jsr prog8_lib.strlen tya ldx cx16.r0 ldy cx16.r0+1 - jsr c64.SETNAM + jsr cbm.SETNAM pla clc adc #2 ldx cx16.r1 ldy cx16.r1+1 stz P8ZP_SCRATCH_B1 - jsr c64.LOAD + jsr cbm.LOAD bcs + inc P8ZP_SCRATCH_B1 - + jsr c64.CLRCHN + + jsr cbm.CLRCHN lda #1 - jsr c64.CLOSE + jsr cbm.CLOSE plx lda P8ZP_SCRATCH_B1 rts @@ -114,7 +114,7 @@ internal_vload: if msb(bufferpointer) == $c0 bufferpointer = mkword($a0, lsb(bufferpointer)) ; wrap over bank boundary num_bytes -= size - if c64.READST() & $40 { + if cbm.READST() & $40 { diskio.f_close() ; end of file, close it break } @@ -129,14 +129,14 @@ byte_read_loop: ; fallback if macptr() isn't supported on the device sta m_in_buffer+2 }} while num_bytes { - if c64.READST() { + if cbm.READST() { diskio.f_close() - if c64.READST() & $40 ; eof? + if cbm.READST() & $40 ; eof? return diskio.list_blocks ; number of bytes read return 0 ; error. } %asm {{ - jsr c64.CHRIN + jsr cbm.CHRIN m_in_buffer sta $ffff inc m_in_buffer+1 bne + @@ -157,7 +157,7 @@ m_in_buffer sta $ffff return 0 uword total_read = 0 - while not c64.READST() { + while not cbm.READST() { cx16.r0 = cx16diskio.f_read(bufferpointer, 256) total_read += cx16.r0 bufferpointer += cx16.r0 @@ -215,10 +215,10 @@ m_in_buffer sta $ffff command[4] = lsb(pos_hiword) command[5] = msb(pos_hiword) send_command: - c64.SETNAM(sizeof(command), &command) - c64.SETLFS(15, diskio.last_drivenumber, 15) - void c64.OPEN() - c64.CLOSE(15) + cbm.SETNAM(sizeof(command), &command) + cbm.SETLFS(15, diskio.last_drivenumber, 15) + void cbm.OPEN() + cbm.CLOSE(15) } ; TODO see if we can get this to work as well: diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index 63d076976..21e33abf7 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -84,7 +84,7 @@ gfx2 { else -> { ; back to default text mode cx16.r15L = cx16.VERA_DC_VIDEO & %00000111 ; retain chroma + output mode - c64.CINT() + cbm.CINT() cx16.VERA_DC_VIDEO = (cx16.VERA_DC_VIDEO & %11111000) | cx16.r15L width = 0 height = 0 diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 75bdce75b..559727da9 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -1,9 +1,9 @@ ; Prog8 definitions for the CommanderX16 ; Including memory registers, I/O registers, Basic and Kernal subroutines. -c64 { +cbm { -; ---- kernal routines, these are the same as on the Commodore-64 (hence the same block name) ---- + ; Commodore (CBM) common variables, vectors and kernal routines ; STROUT --> use txt.print ; CLEARSCR -> use txt.clear_screen @@ -55,7 +55,7 @@ asmsub STOP2() -> ubyte @A { ; -- check if STOP key was pressed, returns true if so. More convenient to use than STOP() because that only sets the carry status flag. %asm {{ phx - jsr c64.STOP + jsr cbm.STOP beq + plx lda #0 @@ -70,7 +70,7 @@ asmsub RDTIM16() -> uword @AY { ; -- like RDTIM() but only returning the lower 16 bits in AY for convenience %asm {{ phx - jsr c64.RDTIM + jsr cbm.RDTIM pha txa tay @@ -85,37 +85,37 @@ asmsub RDTIM16() -> uword @AY { cx16 { ; irq, system and hardware vectors: - &uword IERROR = $0300 - &uword IMAIN = $0302 - &uword ICRNCH = $0304 - &uword IQPLOP = $0306 - &uword IGONE = $0308 - &uword IEVAL = $030a - &ubyte SAREG = $030c ; register storage for A for SYS calls - &ubyte SXREG = $030d ; register storage for X for SYS calls - &ubyte SYREG = $030e ; register storage for Y for SYS calls - &ubyte SPREG = $030f ; register storage for P (status register) for SYS calls - &uword USRADD = $0311 ; vector for the USR() basic command + &uword IERROR = $0300 + &uword IMAIN = $0302 + &uword ICRNCH = $0304 + &uword IQPLOP = $0306 + &uword IGONE = $0308 + &uword IEVAL = $030a + &ubyte SAREG = $030c ; register storage for A for SYS calls + &ubyte SXREG = $030d ; register storage for X for SYS calls + &ubyte SYREG = $030e ; register storage for Y for SYS calls + &ubyte SPREG = $030f ; register storage for P (status register) for SYS calls + &uword USRADD = $0311 ; vector for the USR() basic command ; $0313 is unused. - &uword CINV = $0314 ; IRQ vector (in ram) - &uword CBINV = $0316 ; BRK vector (in ram) - &uword NMINV = $0318 ; NMI vector (in ram) - &uword IOPEN = $031a - &uword ICLOSE = $031c - &uword ICHKIN = $031e - &uword ICKOUT = $0320 - &uword ICLRCH = $0322 - &uword IBASIN = $0324 - &uword IBSOUT = $0326 - &uword ISTOP = $0328 - &uword IGETIN = $032a - &uword ICLALL = $032c - &uword KEYHDL = $032e ; keyboard scan code handler see examples/cx16/keyboardhandler.p8 - &uword ILOAD = $0330 - &uword ISAVE = $0332 - &uword NMI_VEC = $FFFA ; 65c02 nmi vector, determined by the kernal if banked in - &uword RESET_VEC = $FFFC ; 65c02 reset vector, determined by the kernal if banked in - &uword IRQ_VEC = $FFFE ; 65c02 interrupt vector, determined by the kernal if banked in + &uword CINV = $0314 ; IRQ vector (in ram) + &uword CBINV = $0316 ; BRK vector (in ram) + &uword NMINV = $0318 ; NMI vector (in ram) + &uword IOPEN = $031a + &uword ICLOSE = $031c + &uword ICHKIN = $031e + &uword ICKOUT = $0320 + &uword ICLRCH = $0322 + &uword IBASIN = $0324 + &uword IBSOUT = $0326 + &uword ISTOP = $0328 + &uword IGETIN = $032a + &uword ICLALL = $032c + &uword KEYHDL = $032e ; keyboard scan code handler see examples/cx16/keyboardhandler.p8 + &uword ILOAD = $0330 + &uword ISAVE = $0332 + &uword NMI_VEC = $FFFA ; 65c02 nmi vector, determined by the kernal if banked in + &uword RESET_VEC = $FFFC ; 65c02 reset vector, determined by the kernal if banked in + &uword IRQ_VEC = $FFFE ; 65c02 interrupt vector, determined by the kernal if banked in ; the sixteen virtual 16-bit registers in both normal unsigned mode and signed mode (s) @@ -271,44 +271,44 @@ cx16 { ; I/O const uword VIA1_BASE = $9f00 ;VIA 6522 #1 - &ubyte via1prb = VIA1_BASE + 0 - &ubyte via1pra = VIA1_BASE + 1 - &ubyte via1ddrb = VIA1_BASE + 2 - &ubyte via1ddra = VIA1_BASE + 3 - &ubyte via1t1l = VIA1_BASE + 4 - &ubyte via1t1h = VIA1_BASE + 5 - &ubyte via1t1ll = VIA1_BASE + 6 - &ubyte via1t1lh = VIA1_BASE + 7 - &ubyte via1t2l = VIA1_BASE + 8 - &ubyte via1t2h = VIA1_BASE + 9 - &ubyte via1sr = VIA1_BASE + 10 - &ubyte via1acr = VIA1_BASE + 11 - &ubyte via1pcr = VIA1_BASE + 12 - &ubyte via1ifr = VIA1_BASE + 13 - &ubyte via1ier = VIA1_BASE + 14 - &ubyte via1ora = VIA1_BASE + 15 + &ubyte via1prb = VIA1_BASE + 0 + &ubyte via1pra = VIA1_BASE + 1 + &ubyte via1ddrb = VIA1_BASE + 2 + &ubyte via1ddra = VIA1_BASE + 3 + &ubyte via1t1l = VIA1_BASE + 4 + &ubyte via1t1h = VIA1_BASE + 5 + &ubyte via1t1ll = VIA1_BASE + 6 + &ubyte via1t1lh = VIA1_BASE + 7 + &ubyte via1t2l = VIA1_BASE + 8 + &ubyte via1t2h = VIA1_BASE + 9 + &ubyte via1sr = VIA1_BASE + 10 + &ubyte via1acr = VIA1_BASE + 11 + &ubyte via1pcr = VIA1_BASE + 12 + &ubyte via1ifr = VIA1_BASE + 13 + &ubyte via1ier = VIA1_BASE + 14 + &ubyte via1ora = VIA1_BASE + 15 const uword VIA2_BASE = $9f10 ;VIA 6522 #2 - &ubyte via2prb = VIA2_BASE + 0 - &ubyte via2pra = VIA2_BASE + 1 - &ubyte via2ddrb = VIA2_BASE + 2 - &ubyte via2ddra = VIA2_BASE + 3 - &ubyte via2t1l = VIA2_BASE + 4 - &ubyte via2t1h = VIA2_BASE + 5 - &ubyte via2t1ll = VIA2_BASE + 6 - &ubyte via2t1lh = VIA2_BASE + 7 - &ubyte via2t2l = VIA2_BASE + 8 - &ubyte via2t2h = VIA2_BASE + 9 - &ubyte via2sr = VIA2_BASE + 10 - &ubyte via2acr = VIA2_BASE + 11 - &ubyte via2pcr = VIA2_BASE + 12 - &ubyte via2ifr = VIA2_BASE + 13 - &ubyte via2ier = VIA2_BASE + 14 - &ubyte via2ora = VIA2_BASE + 15 + &ubyte via2prb = VIA2_BASE + 0 + &ubyte via2pra = VIA2_BASE + 1 + &ubyte via2ddrb = VIA2_BASE + 2 + &ubyte via2ddra = VIA2_BASE + 3 + &ubyte via2t1l = VIA2_BASE + 4 + &ubyte via2t1h = VIA2_BASE + 5 + &ubyte via2t1ll = VIA2_BASE + 6 + &ubyte via2t1lh = VIA2_BASE + 7 + &ubyte via2t2l = VIA2_BASE + 8 + &ubyte via2t2h = VIA2_BASE + 9 + &ubyte via2sr = VIA2_BASE + 10 + &ubyte via2acr = VIA2_BASE + 11 + &ubyte via2pcr = VIA2_BASE + 12 + &ubyte via2ifr = VIA2_BASE + 13 + &ubyte via2ier = VIA2_BASE + 14 + &ubyte via2ora = VIA2_BASE + 15 ; YM-2151 sound chip &ubyte YM_ADDRESS = $9f40 - &ubyte YM_DATA = $9f41 + &ubyte YM_DATA = $9f41 const uword extdev = $9f60 @@ -409,7 +409,7 @@ romsub $C09F = audio_init() clobbers(A,X,Y) -> ubyte @Pc ; (re)in asmsub kbdbuf_clear() { ; -- convenience helper routine to clear the keyboard buffer %asm {{ -- jsr c64.GETIN +- jsr cbm.GETIN bne - rts }} @@ -482,7 +482,7 @@ asmsub numbanks() -> uword @AY { %asm {{ phx sec - jsr c64.MEMTOP + jsr cbm.MEMTOP ldy #0 cmp #0 bne + @@ -624,7 +624,63 @@ asmsub vpoke_mask(ubyte bank @A, uword address @R0, ubyte mask @X, ubyte value @ }} } -; ---- system stuff ----- +asmsub save_vera_context() clobbers(A) { + ; -- use this at the start of your IRQ handler if it uses Vera registers, to save the state + %asm {{ + ; note cannot store this on cpu hardware stack because this gets called as a subroutine + lda cx16.VERA_ADDR_L + sta _vera_storage + lda cx16.VERA_ADDR_M + sta _vera_storage+1 + lda cx16.VERA_ADDR_H + sta _vera_storage+2 + lda cx16.VERA_CTRL + sta _vera_storage+3 + eor #1 + sta cx16.VERA_CTRL + lda cx16.VERA_ADDR_L + sta _vera_storage+4 + lda cx16.VERA_ADDR_M + sta _vera_storage+5 + lda cx16.VERA_ADDR_H + sta _vera_storage+6 + lda cx16.VERA_CTRL + sta _vera_storage+7 + rts +_vera_storage: .byte 0,0,0,0,0,0,0,0 + }} +} + +asmsub restore_vera_context() clobbers(A) { + ; -- use this at the end of your IRQ handler if it uses Vera registers, to restore the state + %asm {{ + lda cx16.save_vera_context._vera_storage+7 + sta cx16.VERA_CTRL + lda cx16.save_vera_context._vera_storage+6 + sta cx16.VERA_ADDR_H + lda cx16.save_vera_context._vera_storage+5 + sta cx16.VERA_ADDR_M + lda cx16.save_vera_context._vera_storage+4 + sta cx16.VERA_ADDR_L + lda cx16.save_vera_context._vera_storage+3 + sta cx16.VERA_CTRL + lda cx16.save_vera_context._vera_storage+2 + sta cx16.VERA_ADDR_H + lda cx16.save_vera_context._vera_storage+1 + sta cx16.VERA_ADDR_M + lda cx16.save_vera_context._vera_storage+0 + sta cx16.VERA_ADDR_L + rts + }} +} + +} + +sys { + ; ------- lowlevel system routines -------- + + const ubyte target = 16 ; compilation target specifier. 64 = C64, 128 = C128, 16 = CommanderX16. + asmsub init_system() { ; Initializes the machine to a sane starting state. ; Called automatically by the loader program logic. @@ -635,29 +691,29 @@ asmsub init_system() { tay jsr cx16.mouse_config ; disable mouse cld - lda VERA_DC_VIDEO + lda cx16.VERA_DC_VIDEO and #%00000111 ; retain chroma + output mode sta P8ZP_SCRATCH_REG lda #$0a sta $01 ; rom bank 10 (audio) - jsr audio_init ; silence + jsr cx16.audio_init ; silence stz $01 ; rom bank 0 (kernal) - jsr c64.IOINIT - jsr c64.RESTOR - jsr c64.CINT - lda VERA_DC_VIDEO + jsr cbm.IOINIT + jsr cbm.RESTOR + jsr cbm.CINT + lda cx16.VERA_DC_VIDEO and #%11111000 ora P8ZP_SCRATCH_REG - sta VERA_DC_VIDEO ; restore old output mode + sta cx16.VERA_DC_VIDEO ; restore old output mode lda #$90 ; black - jsr c64.CHROUT + jsr cbm.CHROUT lda #1 sta $00 ; select ram bank 1 - jsr c64.CHROUT ; swap fg/bg + jsr cbm.CHROUT ; swap fg/bg lda #$9e ; yellow - jsr c64.CHROUT + jsr cbm.CHROUT lda #147 ; clear screen - jsr c64.CHROUT + jsr cbm.CHROUT lda #0 tax tay @@ -694,21 +750,21 @@ asmsub cleanup_at_exit() { asmsub set_irq(uword handler @AY, ubyte useKernal @Pc) clobbers(A) { %asm {{ - sta _modified+1 - sty _modified+2 - lda #0 - adc #0 - sta _use_kernal - sei - lda #<_irq_handler - sta cx16.CINV - lda #>_irq_handler - sta cx16.CINV+1 - lda cx16.VERA_IEN - ora #%00000001 ; enable the vsync irq - sta cx16.VERA_IEN - cli - rts + sta _modified+1 + sty _modified+2 + lda #0 + adc #0 + sta _use_kernal + sei + lda #<_irq_handler + sta cx16.CINV + lda #>_irq_handler + sta cx16.CINV+1 + lda cx16.VERA_IEN + ora #%00000001 ; enable the vsync irq + sta cx16.VERA_IEN + cli + rts _irq_handler jsr _irq_handler_init _modified jsr $ffff ; modified @@ -771,57 +827,6 @@ IRQ_SCRATCH_ZPWORD2 .word 0 }} } -asmsub save_vera_context() clobbers(A) { - ; -- use this at the start of your IRQ handler if it uses Vera registers, to save the state - %asm {{ - ; note cannot store this on cpu hardware stack because this gets called as a subroutine - lda cx16.VERA_ADDR_L - sta _vera_storage - lda cx16.VERA_ADDR_M - sta _vera_storage+1 - lda cx16.VERA_ADDR_H - sta _vera_storage+2 - lda cx16.VERA_CTRL - sta _vera_storage+3 - eor #1 - sta cx16.VERA_CTRL - lda cx16.VERA_ADDR_L - sta _vera_storage+4 - lda cx16.VERA_ADDR_M - sta _vera_storage+5 - lda cx16.VERA_ADDR_H - sta _vera_storage+6 - lda cx16.VERA_CTRL - sta _vera_storage+7 - rts -_vera_storage: .byte 0,0,0,0,0,0,0,0 - }} -} - -asmsub restore_vera_context() clobbers(A) { - ; -- use this at the end of your IRQ handler if it uses Vera registers, to restore the state - %asm {{ - lda cx16.save_vera_context._vera_storage+7 - sta cx16.VERA_CTRL - lda cx16.save_vera_context._vera_storage+6 - sta cx16.VERA_ADDR_H - lda cx16.save_vera_context._vera_storage+5 - sta cx16.VERA_ADDR_M - lda cx16.save_vera_context._vera_storage+4 - sta cx16.VERA_ADDR_L - lda cx16.save_vera_context._vera_storage+3 - sta cx16.VERA_CTRL - lda cx16.save_vera_context._vera_storage+2 - sta cx16.VERA_ADDR_H - lda cx16.save_vera_context._vera_storage+1 - sta cx16.VERA_ADDR_M - lda cx16.save_vera_context._vera_storage+0 - sta cx16.VERA_ADDR_L - rts - }} -} - - asmsub restore_irq() clobbers(A) { %asm {{ sei @@ -891,15 +896,6 @@ asmsub set_rasterline(uword line @AY) { }} } -} - - -sys { - ; ------- lowlevel system routines -------- - - const ubyte target = 16 ; compilation target specifier. 64 = C64, 128 = C128, 16 = CommanderX16. - - asmsub reset_system() { ; Soft-reset the system back to initial power-on Basic prompt. ; We do this via the SMC so that a true reset is performed that also resets the Vera fully. @@ -937,9 +933,9 @@ _loop lda P8ZP_SCRATCH_W1 plx rts -+ jsr c64.RDTIM ++ jsr cbm.RDTIM sta P8ZP_SCRATCH_B1 -- jsr c64.RDTIM +- jsr cbm.RDTIM cmp P8ZP_SCRATCH_B1 beq - @@ -1082,7 +1078,7 @@ _longcopy inline asmsub exit(ubyte returnvalue @A) { ; -- immediately exit the program with a return code in the A register %asm {{ - jsr c64.CLRCHN ; reset i/o channels + jsr cbm.CLRCHN ; reset i/o channels ldx prog8_lib.orig_stackpointer txs rts ; return to original caller diff --git a/compiler/res/prog8lib/cx16/textio.p8 b/compiler/res/prog8lib/cx16/textio.p8 index ce61d7f6f..de13d8847 100644 --- a/compiler/res/prog8lib/cx16/textio.p8 +++ b/compiler/res/prog8lib/cx16/textio.p8 @@ -33,10 +33,10 @@ asmsub column(ubyte col @A) clobbers(A, X, Y) { ; ---- set the cursor on the given column (starting with 0) on the current line %asm {{ sec - jsr c64.PLOT + jsr cbm.PLOT tay clc - jmp c64.PLOT + jmp cbm.PLOT }} } @@ -46,7 +46,7 @@ asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) { sty _ly+1 phx pha - jsr c64.SCREEN ; get dimensions in X/Y + jsr cbm.SCREEN ; get dimensions in X/Y txa lsr a lsr a @@ -94,7 +94,7 @@ asmsub clear_screenchars (ubyte char @ A) clobbers(Y) { %asm {{ phx pha - jsr c64.SCREEN ; get dimensions in X/Y + jsr cbm.SCREEN ; get dimensions in X/Y txa lsr a lsr a @@ -125,7 +125,7 @@ asmsub clear_screencolors (ubyte color @ A) clobbers(Y) { %asm {{ phx sta _la+1 - jsr c64.SCREEN ; get dimensions in X/Y + jsr cbm.SCREEN ; get dimensions in X/Y txa lsr a lsr a @@ -158,35 +158,35 @@ ubyte[16] color_to_charcode = [$90,$05,$1c,$9f,$9c,$1e,$1f,$9e,$81,$95,$96,$97,$ sub color (ubyte txtcol) { txtcol &= 15 - c64.CHROUT(color_to_charcode[txtcol]) + cbm.CHROUT(color_to_charcode[txtcol]) } sub color2 (ubyte txtcol, ubyte bgcol) { txtcol &= 15 bgcol &= 15 - c64.CHROUT(color_to_charcode[bgcol]) - c64.CHROUT(1) ; switch fg and bg colors - c64.CHROUT(color_to_charcode[txtcol]) + cbm.CHROUT(color_to_charcode[bgcol]) + cbm.CHROUT(1) ; switch fg and bg colors + cbm.CHROUT(color_to_charcode[txtcol]) } sub lowercase() { - c64.CHROUT($0e) + cbm.CHROUT($0e) ; this is not 100% compatible: cx16.screen_set_charset(3, 0) ; lowercase petscii charset } sub uppercase() { - c64.CHROUT($8e) + cbm.CHROUT($8e) ; this is not 100% compatible: cx16.screen_set_charset(2, 0) ; uppercase petscii charset } sub iso() { - c64.CHROUT($0f) + cbm.CHROUT($0f) ; This doesn't enable it completely: cx16.screen_set_charset(1, 0) ; iso charset } sub iso_off() { ; -- you have to call this first when switching back from iso charset to regular charset. - c64.CHROUT($8f) + cbm.CHROUT($8f) } @@ -195,7 +195,7 @@ asmsub scroll_left() clobbers(A, Y) { ; contents of the rightmost column are unchanged, you should clear/refill this yourself %asm {{ phx - jsr c64.SCREEN + jsr cbm.SCREEN dex stx _lx+1 dey @@ -241,7 +241,7 @@ asmsub scroll_right() clobbers(A) { ; contents of the leftmost column are unchanged, you should clear/refill this yourself %asm {{ phx - jsr c64.SCREEN + jsr cbm.SCREEN dex stx _lx+1 txa @@ -295,7 +295,7 @@ asmsub scroll_up() clobbers(A, Y) { ; contents of the bottom row are unchanged, you should refill/clear this yourself %asm {{ phx - jsr c64.SCREEN + jsr cbm.SCREEN stx _nextline+1 dey sty P8ZP_SCRATCH_B1 @@ -345,7 +345,7 @@ asmsub scroll_down() clobbers(A, Y) { ; contents of the top row are unchanged, you should refill/clear this yourself %asm {{ phx - jsr c64.SCREEN + jsr cbm.SCREEN stx _nextline+1 dey sty P8ZP_SCRATCH_B1 @@ -396,20 +396,20 @@ _nextline }} } -romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use c64.CHROUT directly ofcourse. +romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use cbm.CHROUT directly ofcourse. asmsub print (str text @ AY) clobbers(A,Y) { ; ---- print null terminated string from A/Y ; note: the compiler contains an optimization that will replace ; a call to this subroutine with a string argument of just one char, - ; by just one call to c64.CHROUT of that single char. + ; by just one call to cbm.CHROUT of that single char. %asm {{ sta P8ZP_SCRATCH_B1 sty P8ZP_SCRATCH_REG ldy #0 - lda (P8ZP_SCRATCH_B1),y beq + - jsr c64.CHROUT + jsr cbm.CHROUT iny bne - + rts @@ -423,11 +423,11 @@ asmsub print_ub0 (ubyte value @ A) clobbers(A,Y) { jsr conv.ubyte2decimal pha tya - jsr c64.CHROUT + jsr cbm.CHROUT pla - jsr c64.CHROUT + jsr cbm.CHROUT txa - jsr c64.CHROUT + jsr cbm.CHROUT plx rts }} @@ -443,16 +443,16 @@ _print_byte_digits cpy #'0' beq + tya - jsr c64.CHROUT + jsr cbm.CHROUT pla - jsr c64.CHROUT + jsr cbm.CHROUT bra _ones + pla cmp #'0' beq _ones - jsr c64.CHROUT + jsr cbm.CHROUT _ones txa - jsr c64.CHROUT + jsr cbm.CHROUT plx rts }} @@ -466,7 +466,7 @@ asmsub print_b (byte value @ A) clobbers(A,Y) { cmp #0 bpl + lda #'-' - jsr c64.CHROUT + jsr cbm.CHROUT + pla jsr conv.byte2decimal bra print_ub._print_byte_digits @@ -480,12 +480,12 @@ asmsub print_ubhex (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) { bcc + pha lda #'$' - jsr c64.CHROUT + jsr cbm.CHROUT pla + jsr conv.ubyte2hex - jsr c64.CHROUT + jsr cbm.CHROUT tya - jsr c64.CHROUT + jsr cbm.CHROUT plx rts }} @@ -498,13 +498,13 @@ asmsub print_ubbin (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) { sta P8ZP_SCRATCH_B1 bcc + lda #'%' - jsr c64.CHROUT + jsr cbm.CHROUT + ldy #8 - lda #'0' asl P8ZP_SCRATCH_B1 bcc + lda #'1' -+ jsr c64.CHROUT ++ jsr cbm.CHROUT dey bne - plx @@ -545,7 +545,7 @@ asmsub print_uw0 (uword value @ AY) clobbers(A,Y) { ldy #0 - lda conv.uword2decimal.decTenThousands,y beq + - jsr c64.CHROUT + jsr cbm.CHROUT iny bne - + plx @@ -568,14 +568,14 @@ asmsub print_uw (uword value @ AY) clobbers(A,Y) { bne - _gotdigit - jsr c64.CHROUT + jsr cbm.CHROUT iny lda conv.uword2decimal.decTenThousands,y bne _gotdigit rts _allzero lda #'0' - jmp c64.CHROUT + jmp cbm.CHROUT }} } @@ -586,7 +586,7 @@ asmsub print_w (word value @ AY) clobbers(A,Y) { bpl + pha lda #'-' - jsr c64.CHROUT + jsr cbm.CHROUT tya eor #255 tay @@ -607,7 +607,7 @@ asmsub input_chars (uword buffer @ AY) clobbers(A) -> ubyte @ Y { sta P8ZP_SCRATCH_W1 sty P8ZP_SCRATCH_W1+1 ldy #0 ; char counter = 0 -- jsr c64.CHRIN +- jsr cbm.CHRIN cmp #$0d ; return (ascii 13) pressed? beq + ; yes, end. sta (P8ZP_SCRATCH_W1),y ; else store char in buffer @@ -769,7 +769,7 @@ asmsub plot (ubyte col @ Y, ubyte row @ A) clobbers(A) { phx tax clc - jsr c64.PLOT + jsr cbm.PLOT plx rts }} @@ -778,7 +778,7 @@ asmsub plot (ubyte col @ Y, ubyte row @ A) clobbers(A) { asmsub width() clobbers(X,Y) -> ubyte @A { ; -- returns the text screen width (number of columns) %asm {{ - jsr c64.SCREEN + jsr cbm.SCREEN txa rts }} @@ -787,7 +787,7 @@ asmsub width() clobbers(X,Y) -> ubyte @A { asmsub height() clobbers(X, Y) -> ubyte @A { ; -- returns the text screen height (number of rows) %asm {{ - jsr c64.SCREEN + jsr cbm.SCREEN tya rts }} diff --git a/compiler/res/prog8lib/diskio.p8 b/compiler/res/prog8lib/diskio.p8 index 74fadc874..53cbb3b08 100644 --- a/compiler/res/prog8lib/diskio.p8 +++ b/compiler/res/prog8lib/diskio.p8 @@ -9,51 +9,51 @@ diskio { sub directory(ubyte drivenumber) -> bool { ; -- Prints the directory contents of disk drive 8-11 to the screen. Returns success. - c64.SETNAM(1, "$") - c64.SETLFS(12, drivenumber, 0) + cbm.SETNAM(1, "$") + cbm.SETLFS(12, drivenumber, 0) ubyte status = 1 - void c64.OPEN() ; open 12,8,0,"$" + void cbm.OPEN() ; open 12,8,0,"$" if_cs goto io_error - void c64.CHKIN(12) ; use #12 as input channel + void cbm.CHKIN(12) ; use #12 as input channel if_cs goto io_error repeat 4 { - void c64.CHRIN() ; skip the 4 prologue bytes + void cbm.CHRIN() ; skip the 4 prologue bytes } ; while not stop key pressed / EOF encountered, read data. - status = c64.READST() + status = cbm.READST() if status!=0 { status = 1 goto io_error } while status==0 { - ubyte low = c64.CHRIN() - ubyte high = c64.CHRIN() + ubyte low = cbm.CHRIN() + ubyte high = cbm.CHRIN() txt.print_uw(mkword(high, low)) txt.spc() ubyte @zp char repeat { - char = c64.CHRIN() + char = cbm.CHRIN() if char==0 break txt.chrout(char) } txt.nl() - void c64.CHRIN() ; skip 2 bytes - void c64.CHRIN() - status = c64.READST() - if c64.STOP2() + void cbm.CHRIN() ; skip 2 bytes + void cbm.CHRIN() + status = cbm.READST() + if cbm.STOP2() break } - status = c64.READST() + status = cbm.READST() io_error: - c64.CLRCHN() ; restore default i/o devices - c64.CLOSE(12) + cbm.CLRCHN() ; restore default i/o devices + cbm.CLOSE(12) if status and status & $40 == 0 { ; bit 6=end of file txt.print("\ni/o error, status: ") @@ -68,25 +68,25 @@ io_error: sub diskname(ubyte drivenumber) -> uword { ; -- Returns pointer to disk name string or 0 if failure. - c64.SETNAM(1, "$") - c64.SETLFS(12, drivenumber, 0) + cbm.SETNAM(1, "$") + cbm.SETLFS(12, drivenumber, 0) ubyte okay = false - void c64.OPEN() ; open 12,8,0,"$" + void cbm.OPEN() ; open 12,8,0,"$" if_cs goto io_error - void c64.CHKIN(12) ; use #12 as input channel + void cbm.CHKIN(12) ; use #12 as input channel if_cs goto io_error repeat 6 { - void c64.CHRIN() ; skip the 6 prologue bytes + void cbm.CHRIN() ; skip the 6 prologue bytes } - if c64.READST()!=0 + if cbm.READST()!=0 goto io_error cx16.r0 = &list_filename repeat { - @(cx16.r0) = c64.CHRIN() + @(cx16.r0) = cbm.CHRIN() if @(cx16.r0)==0 break cx16.r0++ @@ -94,8 +94,8 @@ io_error: okay = true io_error: - c64.CLRCHN() ; restore default i/o devices - c64.CLOSE(12) + cbm.CLRCHN() ; restore default i/o devices + cbm.CLOSE(12) if okay return &list_filename return 0 @@ -150,20 +150,20 @@ io_error: list_skip_disk_name = true iteration_in_progress = true - c64.SETNAM(1, "$") - c64.SETLFS(12, drivenumber, 0) - void c64.OPEN() ; open 12,8,0,"$" + cbm.SETNAM(1, "$") + cbm.SETLFS(12, drivenumber, 0) + void cbm.OPEN() ; open 12,8,0,"$" if_cs goto io_error - void c64.CHKIN(12) ; use #12 as input channel + void cbm.CHKIN(12) ; use #12 as input channel if_cs goto io_error repeat 4 { - void c64.CHRIN() ; skip the 4 prologue bytes + void cbm.CHRIN() ; skip the 4 prologue bytes } - if c64.READST()==0 + if cbm.READST()==0 return true io_error: @@ -180,26 +180,26 @@ io_error: return false repeat { - void c64.CHKIN(12) ; use #12 as input channel again + void cbm.CHKIN(12) ; use #12 as input channel again uword nameptr = &list_filename - ubyte blocks_lsb = c64.CHRIN() - ubyte blocks_msb = c64.CHRIN() + ubyte blocks_lsb = cbm.CHRIN() + ubyte blocks_msb = cbm.CHRIN() - if c64.READST() + if cbm.READST() goto close_end list_blocks = mkword(blocks_msb, blocks_lsb) ; read until the filename starts after the first " - while c64.CHRIN()!='\"' { - if c64.READST() + while cbm.CHRIN()!='\"' { + if cbm.READST() goto close_end } ; read the filename repeat { - ubyte char = c64.CHRIN() + ubyte char = cbm.CHRIN() if char==0 break if char=='\"' @@ -211,17 +211,17 @@ io_error: @(nameptr) = 0 do { - cx16.r15L = c64.CHRIN() + cx16.r15L = cbm.CHRIN() } until cx16.r15L!=' ' ; skip blanks up to 3 chars entry type list_filetype[0] = cx16.r15L - list_filetype[1] = c64.CHRIN() - list_filetype[2] = c64.CHRIN() - while c64.CHRIN() { + list_filetype[1] = cbm.CHRIN() + list_filetype[2] = cbm.CHRIN() + while cbm.CHRIN() { ; read the rest of the entry until the end } - void c64.CHRIN() ; skip 2 bytes - void c64.CHRIN() + void cbm.CHRIN() ; skip 2 bytes + void cbm.CHRIN() if not list_skip_disk_name { if not list_pattern @@ -240,8 +240,8 @@ close_end: sub lf_end_list() { ; -- end an iterative file listing session (close channels). if iteration_in_progress { - c64.CLRCHN() - c64.CLOSE(12) + cbm.CLRCHN() + cbm.CLOSE(12) iteration_in_progress = false } } @@ -254,20 +254,20 @@ close_end: ; note: only a single iteration loop can be active at a time! f_close() - c64.SETNAM(string.length(filenameptr), filenameptr) - c64.SETLFS(12, drivenumber, 12) ; note: has to be 12,x,12 because otherwise f_seek doesn't work + cbm.SETNAM(string.length(filenameptr), filenameptr) + cbm.SETLFS(12, drivenumber, 12) ; note: has to be 12,x,12 because otherwise f_seek doesn't work last_drivenumber = drivenumber - void c64.OPEN() ; open 12,8,12,"filename" + void cbm.OPEN() ; open 12,8,12,"filename" if_cc { - if c64.READST()==0 { + if cbm.READST()==0 { iteration_in_progress = true - void c64.CHKIN(12) ; use #12 as input channel + void cbm.CHKIN(12) ; use #12 as input channel if_cc { - void c64.CHRIN() ; read first byte to test for file not found - if not c64.READST() { - c64.CLOSE(12) ; close file because we already consumed first byte - void c64.OPEN() ; re-open the file - void c64.CHKIN(12) + void cbm.CHRIN() ; read first byte to test for file not found + if not cbm.READST() { + cbm.CLOSE(12) ; close file because we already consumed first byte + void cbm.OPEN() ; re-open the file + void cbm.CHKIN(12) return true } } @@ -295,14 +295,14 @@ close_end: sta m_in_buffer+2 }} while num_bytes { - if c64.READST() { + if cbm.READST() { f_close() - if c64.READST() & $40 ; eof? + if cbm.READST() & $40 ; eof? return list_blocks ; number of bytes read return 0 ; error. } %asm {{ - jsr c64.CHRIN + jsr cbm.CHRIN m_in_buffer sta $ffff inc m_in_buffer+1 bne + @@ -322,7 +322,7 @@ m_in_buffer sta $ffff return 0 uword total_read = 0 - while not c64.READST() { + while not cbm.READST() { cx16.r0 = f_read(bufferpointer, 256) total_read += cx16.r0 bufferpointer += cx16.r0 @@ -340,9 +340,9 @@ m_in_buffer sta $ffff sta P8ZP_SCRATCH_W1 sty P8ZP_SCRATCH_W1+1 ldx #12 - jsr c64.CHKIN ; use channel 12 again for input + jsr cbm.CHKIN ; use channel 12 again for input ldy #0 -_loop jsr c64.CHRIN +_loop jsr cbm.CHRIN sta (P8ZP_SCRATCH_W1),y beq _end iny @@ -361,8 +361,8 @@ _end rts sub f_close() { ; -- end an iterative file loading session (close channels). if iteration_in_progress { - c64.CLRCHN() - c64.CLOSE(12) + cbm.CLRCHN() + cbm.CLOSE(12) iteration_in_progress = false } } @@ -374,12 +374,12 @@ _end rts ; -- open a file for iterative writing with f_write f_close_w() - c64.SETNAM(string.length(filenameptr), filenameptr) - c64.SETLFS(13, drivenumber, 1) - void c64.OPEN() ; open 13,8,1,"filename" + cbm.SETNAM(string.length(filenameptr), filenameptr) + cbm.SETLFS(13, drivenumber, 1) + void cbm.OPEN() ; open 13,8,1,"filename" if_cc { - c64.CHKOUT(13) ; use #13 as output channel - return not c64.READST() + cbm.CHKOUT(13) ; use #13 as output channel + return not cbm.READST() } f_close_w() return false @@ -388,20 +388,20 @@ _end rts sub f_write(uword bufferpointer, uword num_bytes) -> bool { ; -- write the given number of bytes to the currently open file if num_bytes!=0 { - c64.CHKOUT(13) ; use #13 as output channel again + cbm.CHKOUT(13) ; use #13 as output channel again repeat num_bytes { - c64.CHROUT(@(bufferpointer)) + cbm.CHROUT(@(bufferpointer)) bufferpointer++ } - return not c64.READST() + return not cbm.READST() } return true } sub f_close_w() { ; -- end an iterative file writing session (close channels). - c64.CLRCHN() - c64.CLOSE(13) + cbm.CLRCHN() + cbm.CLOSE(13) } @@ -410,17 +410,17 @@ _end rts sub status(ubyte drivenumber) -> uword { ; -- retrieve the disk drive's current status message uword messageptr = &list_filename - c64.SETNAM(0, list_filename) - c64.SETLFS(15, drivenumber, 15) - void c64.OPEN() ; open 15,8,15 + cbm.SETNAM(0, list_filename) + cbm.SETLFS(15, drivenumber, 15) + void cbm.OPEN() ; open 15,8,15 if_cs goto io_error - void c64.CHKIN(15) ; use #15 as input channel + void cbm.CHKIN(15) ; use #15 as input channel if_cs goto io_error - while not c64.READST() { - cx16.r5L = c64.CHRIN() + while not cbm.READST() { + cx16.r5L = cbm.CHRIN() if cx16.r5L=='\r' or cx16.r5L=='\n' break @(messageptr) = cx16.r5L @@ -429,8 +429,8 @@ _end rts @(messageptr) = 0 done: - c64.CLRCHN() ; restore default i/o devices - c64.CLOSE(15) + cbm.CLRCHN() ; restore default i/o devices + cbm.CLOSE(15) return list_filename io_error: @@ -439,8 +439,8 @@ io_error: } sub save(ubyte drivenumber, uword filenameptr, uword address, uword size) -> bool { - c64.SETNAM(string.length(filenameptr), filenameptr) - c64.SETLFS(1, drivenumber, 0) + cbm.SETNAM(string.length(filenameptr), filenameptr) + cbm.SETLFS(1, drivenumber, 0) uword @shared end_address = address + size cx16.r0L = 0 @@ -453,17 +453,17 @@ io_error: lda # uword { - c64.SETNAM(string.length(filenameptr), filenameptr) + cbm.SETNAM(string.length(filenameptr), filenameptr) ubyte secondary = 1 cx16.r1 = 0 if address_override secondary = 0 if headerless secondary |= %00000010 ; activate cx16 kernal headerless load support - c64.SETLFS(1, drivenumber, secondary) + cbm.SETLFS(1, drivenumber, secondary) %asm {{ stx P8ZP_SCRATCH_REG lda #0 ldx address_override ldy address_override+1 - jsr c64.LOAD + jsr cbm.LOAD bcs + stx cx16.r1 sty cx16.r1+1 + ldx P8ZP_SCRATCH_REG }} - c64.CLRCHN() - c64.CLOSE(1) + cbm.CLRCHN() + cbm.CLOSE(1) return cx16.r1 } @@ -540,11 +540,11 @@ io_error: list_filename[0] = 's' list_filename[1] = ':' ubyte flen = string.copy(filenameptr, &list_filename+2) - c64.SETNAM(flen+2, list_filename) - c64.SETLFS(1, drivenumber, 15) - void c64.OPEN() - c64.CLRCHN() - c64.CLOSE(1) + cbm.SETNAM(flen+2, list_filename) + cbm.SETLFS(1, drivenumber, 15) + void cbm.OPEN() + cbm.CLRCHN() + cbm.CLOSE(1) } sub rename(ubyte drivenumber, uword oldfileptr, uword newfileptr) { @@ -554,19 +554,19 @@ io_error: ubyte flen_new = string.copy(newfileptr, &list_filename+2) list_filename[flen_new+2] = '=' ubyte flen_old = string.copy(oldfileptr, &list_filename+3+flen_new) - c64.SETNAM(3+flen_new+flen_old, list_filename) - c64.SETLFS(1, drivenumber, 15) - void c64.OPEN() - c64.CLRCHN() - c64.CLOSE(1) + cbm.SETNAM(3+flen_new+flen_old, list_filename) + cbm.SETLFS(1, drivenumber, 15) + void cbm.OPEN() + cbm.CLRCHN() + cbm.CLOSE(1) } sub send_command(ubyte drivenumber, uword commandptr) { ; -- send a dos command to the drive - c64.SETNAM(string.length(commandptr), commandptr) - c64.SETLFS(15, drivenumber, 15) - void c64.OPEN() - c64.CLRCHN() - c64.CLOSE(15) + cbm.SETNAM(string.length(commandptr), commandptr) + cbm.SETLFS(15, drivenumber, 15) + void cbm.OPEN() + cbm.CLRCHN() + cbm.CLOSE(15) } } diff --git a/compiler/res/prog8lib/floats_functions.p8 b/compiler/res/prog8lib/floats_functions.p8 index c6d8410e9..cf88643c2 100644 --- a/compiler/res/prog8lib/floats_functions.p8 +++ b/compiler/res/prog8lib/floats_functions.p8 @@ -15,7 +15,7 @@ sub print_f(float value) { ldy #0 - lda (P8ZP_SCRATCH_W1),y beq + - jsr c64.CHROUT + jsr cbm.CHROUT iny bne - + ldx floats_store_reg diff --git a/compiler/res/version.txt b/compiler/res/version.txt index dba148e12..6920989a1 100644 --- a/compiler/res/version.txt +++ b/compiler/res/version.txt @@ -1 +1 @@ -8.13-dev +9.0-dev diff --git a/compiler/test/arithmetic/bitshift.p8 b/compiler/test/arithmetic/bitshift.p8 index 11e779845..39ff3b6a0 100644 --- a/compiler/test/arithmetic/bitshift.p8 +++ b/compiler/test/arithmetic/bitshift.p8 @@ -10,70 +10,70 @@ main { txt.print("ubyte shift left\n") a = shiftlb0() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftlb1() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftlb2() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftlb3() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftlb4() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftlb5() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftlb6() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftlb7() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftlb8() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftlb9() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') txt.print("enter to continue:\n") - void c64.CHRIN() + void cbm.CHRIN() txt.print("ubyte shift right\n") a = shiftrb0() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftrb1() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftrb2() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftrb3() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftrb4() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftrb5() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftrb6() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftrb7() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftrb8() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') a = shiftrb9() txt.print_ubbin(a, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') txt.print("enter to continue:\n") - void c64.CHRIN() + void cbm.CHRIN() @@ -82,70 +82,70 @@ main { byte signedb signedb = shiftlsb0() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftlsb1() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftlsb2() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftlsb3() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftlsb4() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftlsb5() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftlsb6() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftlsb7() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftlsb8() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftlsb9() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') txt.print("enter to continue:\n") - void c64.CHRIN() + void cbm.CHRIN() txt.print("signed byte shift right\n") signedb = shiftrsb0() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftrsb1() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftrsb2() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftrsb3() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftrsb4() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftrsb5() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftrsb6() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftrsb7() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftrsb8() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') signedb = shiftrsb9() txt.print_ubbin(signedb as ubyte, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') txt.print("enter to continue:\n") - void c64.CHRIN() + void cbm.CHRIN() @@ -154,233 +154,233 @@ main { uword uw uw = shiftluw0() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw1() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw2() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw3() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw4() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw5() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw6() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw7() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw8() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw9() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw10() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw11() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw12() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw13() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw14() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw15() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw16() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftluw17() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') txt.print("enter to continue:\n") - void c64.CHRIN() + void cbm.CHRIN() txt.print("uword shift right\n") uw = shiftruw0() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw1() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw2() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw3() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw4() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw5() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw6() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw7() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw8() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw9() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw10() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw11() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw12() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw13() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw14() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw15() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw16() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') uw = shiftruw17() txt.print_uwbin(uw, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') txt.print("enter to continue:\n") - void c64.CHRIN() + void cbm.CHRIN() txt.print("signed word shift left\n") word sw sw = shiftlsw0() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw1() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw2() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw3() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw4() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw5() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw6() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw7() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw8() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw9() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw10() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw11() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw12() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw13() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw14() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw15() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw16() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftlsw17() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') txt.print("enter to continue:\n") - void c64.CHRIN() + void cbm.CHRIN() txt.print("signed word shift right\n") sw = shiftrsw0() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw1() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw2() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw3() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw4() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw5() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw6() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw7() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw8() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw9() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw10() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw11() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw12() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw13() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw14() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw15() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw16() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') sw = shiftrsw17() txt.print_uwbin(sw as uword, true) - c64.CHROUT('\n') + cbm.CHROUT('\n') } diff --git a/compiler/test/arithmetic/div.p8 b/compiler/test/arithmetic/div.p8 index 00672e782..3fc9ccb71 100644 --- a/compiler/test/arithmetic/div.p8 +++ b/compiler/test/arithmetic/div.p8 @@ -37,7 +37,7 @@ main { txt.print_ub(a2) txt.print(" = ") txt.print_ub(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub div_byte(byte a1, byte a2, byte c) { @@ -52,7 +52,7 @@ main { txt.print_b(a2) txt.print(" = ") txt.print_b(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub div_uword(uword a1, uword a2, uword c) { @@ -67,7 +67,7 @@ main { txt.print_uw(a2) txt.print(" = ") txt.print_uw(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub div_word(word a1, word a2, word c) { @@ -82,7 +82,7 @@ main { txt.print_w(a2) txt.print(" = ") txt.print_w(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub div_float(float a1, float a2, float c) { @@ -98,6 +98,6 @@ main { floats.print_f(a2) txt.print(" = ") floats.print_f(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } } diff --git a/compiler/test/arithmetic/minus.p8 b/compiler/test/arithmetic/minus.p8 index 99a0b2fb7..0d76137d5 100644 --- a/compiler/test/arithmetic/minus.p8 +++ b/compiler/test/arithmetic/minus.p8 @@ -48,7 +48,7 @@ main { txt.print_ub(a2) txt.print(" = ") txt.print_ub(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub minus_byte(byte a1, byte a2, byte c) { @@ -63,7 +63,7 @@ main { txt.print_b(a2) txt.print(" = ") txt.print_b(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub minus_uword(uword a1, uword a2, uword c) { @@ -78,7 +78,7 @@ main { txt.print_uw(a2) txt.print(" = ") txt.print_uw(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub minus_word(word a1, word a2, word c) { @@ -93,7 +93,7 @@ main { txt.print_w(a2) txt.print(" = ") txt.print_w(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub minus_float(float a1, float a2, float c) { @@ -110,6 +110,6 @@ main { floats.print_f(a2) txt.print(" = ") floats.print_f(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } } diff --git a/compiler/test/arithmetic/mult.p8 b/compiler/test/arithmetic/mult.p8 index 615cb3f07..2d735ceab 100644 --- a/compiler/test/arithmetic/mult.p8 +++ b/compiler/test/arithmetic/mult.p8 @@ -39,7 +39,7 @@ main { txt.print_ub(a2) txt.print(" = ") txt.print_ub(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub mul_byte(byte a1, byte a2, byte c) { @@ -54,7 +54,7 @@ main { txt.print_b(a2) txt.print(" = ") txt.print_b(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub mul_uword(uword a1, uword a2, uword c) { @@ -69,7 +69,7 @@ main { txt.print_uw(a2) txt.print(" = ") txt.print_uw(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub mul_word(word a1, word a2, word c) { @@ -84,7 +84,7 @@ main { txt.print_w(a2) txt.print(" = ") txt.print_w(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub mul_float(float a1, float a2, float c) { @@ -100,6 +100,6 @@ main { floats.print_f(a2) txt.print(" = ") floats.print_f(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } } diff --git a/compiler/test/arithmetic/plus.p8 b/compiler/test/arithmetic/plus.p8 index 103eb0c47..503220ed1 100644 --- a/compiler/test/arithmetic/plus.p8 +++ b/compiler/test/arithmetic/plus.p8 @@ -43,7 +43,7 @@ main { txt.print_ub(a2) txt.print(" = ") txt.print_ub(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub plus_byte(byte a1, byte a2, byte c) { @@ -58,7 +58,7 @@ main { txt.print_b(a2) txt.print(" = ") txt.print_b(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub plus_uword(uword a1, uword a2, uword c) { @@ -73,7 +73,7 @@ main { txt.print_uw(a2) txt.print(" = ") txt.print_uw(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub plus_word(word a1, word a2, word c) { @@ -88,7 +88,7 @@ main { txt.print_w(a2) txt.print(" = ") txt.print_w(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub plus_float(float a1, float a2, float c) { @@ -104,6 +104,6 @@ main { floats.print_f(a2) txt.print(" = ") floats.print_f(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } } diff --git a/compiler/test/arithmetic/postincrdecr.p8 b/compiler/test/arithmetic/postincrdecr.p8 index 562c27d2b..4a07baca1 100644 --- a/compiler/test/arithmetic/postincrdecr.p8 +++ b/compiler/test/arithmetic/postincrdecr.p8 @@ -85,9 +85,9 @@ main { txt.print("err! ") txt.print(" ubyte ") txt.print_ub(value) - c64.CHROUT(',') + cbm.CHROUT(',') txt.print_ub(expected) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub check_b(byte value, byte expected) { @@ -97,9 +97,9 @@ main { txt.print("err! ") txt.print(" byte ") txt.print_b(value) - c64.CHROUT(',') + cbm.CHROUT(',') txt.print_b(expected) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub check_uw(uword value, uword expected) { @@ -109,9 +109,9 @@ main { txt.print("err! ") txt.print(" uword ") txt.print_uw(value) - c64.CHROUT(',') + cbm.CHROUT(',') txt.print_uw(expected) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub check_w(word value, word expected) { @@ -121,9 +121,9 @@ main { txt.print("err! ") txt.print(" word ") txt.print_w(value) - c64.CHROUT(',') + cbm.CHROUT(',') txt.print_w(expected) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub check_fl(float value, float expected) { @@ -133,8 +133,8 @@ main { txt.print("err! ") txt.print(" float ") floats.print_f(value) - c64.CHROUT(',') + cbm.CHROUT(',') floats.print_f(expected) - c64.CHROUT('\n') + cbm.CHROUT('\n') } } diff --git a/compiler/test/arithmetic/remainder.p8 b/compiler/test/arithmetic/remainder.p8 index 0d1949938..60b741589 100644 --- a/compiler/test/arithmetic/remainder.p8 +++ b/compiler/test/arithmetic/remainder.p8 @@ -27,7 +27,7 @@ main { txt.print_ub(a2) txt.print(" = ") txt.print_ub(r) - c64.CHROUT('\n') + cbm.CHROUT('\n') } sub remainder_uword(uword a1, uword a2, uword c) { @@ -42,6 +42,6 @@ main { txt.print_uw(a2) txt.print(" = ") txt.print_uw(r) - c64.CHROUT('\n') + txt.nl() } } diff --git a/docs/source/programming.rst b/docs/source/programming.rst index ffe57865b..0690b7163 100644 --- a/docs/source/programming.rst +++ b/docs/source/programming.rst @@ -415,8 +415,8 @@ address you specified, and setting the variable will directly modify that memory Direct access to memory locations ('peek' and 'poke') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Normally memory locations are accessed by a *memory mapped* name, such as ``c64.BGCOL0`` that is defined -as the memory mapped address $d021. +Normally memory locations are accessed by a *memory mapped* name, such as ``cbm.BGCOL0`` that is defined +as the memory mapped address $d021 (on the c64 target). If you want to access a memory location directly (by using the address itself or via an uword pointer variable), without defining a memory mapped location, you can do so by enclosing the address in ``@(...)``:: diff --git a/docs/source/syntaxreference.rst b/docs/source/syntaxreference.rst index 40ce6a97f..063fb1230 100644 --- a/docs/source/syntaxreference.rst +++ b/docs/source/syntaxreference.rst @@ -638,10 +638,10 @@ the parameters are strictly passed via cpu registers), are defined with ``asmsub asmsub clear_screenchars (ubyte char @ A) clobbers(Y) { %asm {{ ldy #0 - _loop sta c64.Screen,y - sta c64.Screen+$0100,y - sta c64.Screen+$0200,y - sta c64.Screen+$02e8,y + _loop sta cbm.Screen,y + sta cbm.Screen+$0100,y + sta cbm.Screen+$0200,y + sta cbm.Screen+$02e8,y iny bne _loop rts diff --git a/docs/source/targetsystem.rst b/docs/source/targetsystem.rst index d84914748..9ca90cc25 100644 --- a/docs/source/targetsystem.rst +++ b/docs/source/targetsystem.rst @@ -145,20 +145,16 @@ Normally, the system's default IRQ handling is not interfered with. You can however install your own IRQ handler (for clean separation, it is advised to define it inside its own block). There are a few library routines available to make setting up C64 60hz IRQs and Raster IRQs a lot easier (no assembly code required). -For the C64 these routines are:: +These routines are:: - c64.set_irq(uword handler_address, boolean useKernal) - c64.set_rasterirq(uword handler_address, uword rasterline, boolean useKernal) - c64.restore_irq() ; set everything back to the systems default irq handler + sys.set_irq(uword handler_address, boolean useKernal) + sys.set_rasterirq(uword handler_address, uword rasterline, boolean useKernal) + sys.restore_irq() ; set everything back to the systems default irq handler -And for the Commander X16:: +Note that for the CommanderX16 the "useKernal" parameter doesn't exists for the set_rasterirq() routine; +it will always disable the system IRQ handler (which also means the default sys.wait() routine won't work anymore) - cx16.set_irq(uword handler_address, boolean useKernal) ; vsync irq - cx16.set_rasterirq(uword handler_address, uword rasterline) ; note: disables Kernal irq handler! sys.wait() won't work anymore - cx16.restore_irq() ; set everything back to the systems default irq handler - - -The Commander X16 syslib does provides two additional routines that should be used *in your IRQ handler routine* if it uses the Vera registers. +The Commander X16 syslib provides two additional routines that should be used *in your IRQ handler routine* if it uses the Vera registers. They take care of saving and restoring the Vera state of the interrupted main program, otherwise the IRQ handler's manipulation will corrupt any Vera operations that were going on in the main program. The routines are:: diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 161cc133d..0342f2af5 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,23 +1,13 @@ TODO ==== -New major release 9.0 -^^^^^^^^^^^^^^^^^^^^^^ -- renamed builtin function sqrt16 to sqrtw for consistency - - -For next minor release -^^^^^^^^^^^^^^^^^^^^^^ -- try to optimize newexpr a bit more +- once 9.0 is stable, upgrade other programs (assem, shell, etc) to it. ... For 9.0 major changes ^^^^^^^^^^^^^^^^^^^^^ -- copy (not move) the CBM kernal romsubs to a new 'cbm' block so programs on c128 and cx16 can also - simply refer to cbm.CHROUT rather than c64.CHROUT which looks a bit silly on the non-c64 cbm systems. - we keep the old definitions intact because of backwards compatibility reasons. - try to reintroduce builtin functions max/maxw/min/minw that take 2 args and return the largest/smallest of them. This is a major change because it will likely break existing code that is now using min and max as variable names. Also add optimization that changes the word variant to byte variant if the operands are bytes. diff --git a/examples/balloonflight.p8 b/examples/balloonflight.p8 index 2ed090114..209c32795 100644 --- a/examples/balloonflight.p8 +++ b/examples/balloonflight.p8 @@ -23,7 +23,7 @@ main { c64.SCROLX &= %11110111 ; 38 column mode - c64.set_rasterirq(&irq.irqhandler, 200, false) ; enable animation via raster interrupt + sys.set_rasterirq(&irq.irqhandler, 200, false) ; enable animation via raster interrupt ubyte target_height = 10 ubyte active_height = 24 diff --git a/examples/bdmusic-irq.p8 b/examples/bdmusic-irq.p8 index 6ed3b0e0f..5abc1b090 100644 --- a/examples/bdmusic-irq.p8 +++ b/examples/bdmusic-irq.p8 @@ -6,7 +6,7 @@ main { sub start() { txt.print("playing the music from boulderdash,\nmade in 1984 by peter liepa.\n\n") - c64.set_rasterirq(&irq.irqhandler, 60, true) ; enable playback via raster irq + sys.set_rasterirq(&irq.irqhandler, 60, true) ; enable playback via raster irq } } diff --git a/examples/bdmusic.p8 b/examples/bdmusic.p8 index cef220be6..4155e9829 100644 --- a/examples/bdmusic.p8 +++ b/examples/bdmusic.p8 @@ -14,7 +14,7 @@ sub start() { c64.MVOL = 15 txt.print("will play the music from boulderdash,\nmade in 1984 by peter liepa.\npress enter to start: ") - void c64.CHRIN() + void cbm.CHRIN() txt.clear_screen() repeat { diff --git a/examples/bench8/crc16.p8 b/examples/bench8/crc16.p8 index 42662e808..c9200fd38 100644 --- a/examples/bench8/crc16.p8 +++ b/examples/bench8/crc16.p8 @@ -19,11 +19,11 @@ main { sub start() { txt.print("calculating...") - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) uword crc = crc16($e000, $2000) txt.print_uwhex(crc, true) ; should be $ffd0 txt.nl() - txt.print_uw(c64.RDTIM16()) + txt.print_uw(cbm.RDTIM16()) txt.print(" jiffies") sys.wait(100) } diff --git a/examples/bench8/crc32.p8 b/examples/bench8/crc32.p8 index 070ffe5f5..b231a6e91 100644 --- a/examples/bench8/crc32.p8 +++ b/examples/bench8/crc32.p8 @@ -30,12 +30,12 @@ main { sub start() { txt.print("calculating...") - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) crc32($e000, $2000) txt.print_uwhex(cx16.r0, true) txt.print_uwhex(cx16.r1, false) txt.nl() - txt.print_uw(c64.RDTIM16()) + txt.print_uw(cbm.RDTIM16()) txt.print(" jiffies") sys.wait(100) } diff --git a/examples/bench8/crc8.p8 b/examples/bench8/crc8.p8 index 04f6e2bff..600851c04 100644 --- a/examples/bench8/crc8.p8 +++ b/examples/bench8/crc8.p8 @@ -19,11 +19,11 @@ main { sub start() { txt.print("calculating...") - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) ubyte crc = crc8($e000, $2000) txt.print_ubhex(crc, true) ; should be $a2 txt.nl() - txt.print_uw(c64.RDTIM16()) + txt.print_uw(cbm.RDTIM16()) txt.print(" jiffies") sys.wait(100) } diff --git a/examples/bench8/pow.p8 b/examples/bench8/pow.p8 index 9e9cc7f38..4c677d582 100644 --- a/examples/bench8/pow.p8 +++ b/examples/bench8/pow.p8 @@ -19,7 +19,7 @@ main { sub start() { txt.print("calculating...") - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) float res uword i @@ -35,7 +35,7 @@ main { floats.print_f(res) txt.nl() - txt.print_uw(c64.RDTIM16()) + txt.print_uw(cbm.RDTIM16()) txt.print(" jiffies") sys.wait(100) } diff --git a/examples/bsieve.p8 b/examples/bsieve.p8 index f83f7cffc..d24f70ced 100644 --- a/examples/bsieve.p8 +++ b/examples/bsieve.p8 @@ -9,7 +9,7 @@ main { sub start() { - c64.SETTIM(0, 0, 0) + cbm.SETTIM(0, 0, 0) const ubyte ITERS = 10 uword count @@ -43,7 +43,7 @@ main { txt.print_uw(count) txt.print(" primes\n") - float time = c64.RDTIM16() as float / 60.0 + float time = cbm.RDTIM16() as float / 60.0 floats.print_f(time) txt.print(" sec total = ") floats.print_f(time/ITERS) diff --git a/examples/charset.p8 b/examples/charset.p8 index 71f10e252..9b78e1eca 100644 --- a/examples/charset.p8 +++ b/examples/charset.p8 @@ -14,9 +14,9 @@ main { ; activate the new charset in RAM ubyte block = c64.CIA2PRA - const ubyte PAGE1 = ((c64.Screen >> 6) & $F0) | ((charset.CHARSET >> 10) & $0E) + const ubyte PAGE1 = ((cbm.Screen >> 6) & $F0) | ((charset.CHARSET >> 10) & $0E) - c64.CIA2PRA = (block & $FC) | (lsb(c64.Screen >> 14) ^ $03) + c64.CIA2PRA = (block & $FC) | (lsb(cbm.Screen >> 14) ^ $03) c64.VMCSB = PAGE1 txt.print("\n @ @ @ @\n") diff --git a/examples/cube3d-float.p8 b/examples/cube3d-float.p8 index f2198e8af..fa5c4039e 100644 --- a/examples/cube3d-float.p8 +++ b/examples/cube3d-float.p8 @@ -21,7 +21,7 @@ main { float time=0.0 repeat { - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) rotate_vertices(time) txt.clear_screenchars(' ') @@ -32,7 +32,7 @@ main { txt.print("3d cube! floats. ") - ubyte jiffies = lsb(c64.RDTIM16()) + ubyte jiffies = lsb(cbm.RDTIM16()) txt.print_ub(jiffies) txt.print(" jiffies/fr = ") txt.print_ub(60/jiffies) diff --git a/examples/cube3d-sprites.p8 b/examples/cube3d-sprites.p8 index 719386299..6c2aac5f8 100644 --- a/examples/cube3d-sprites.p8 +++ b/examples/cube3d-sprites.p8 @@ -85,7 +85,7 @@ main { uword angley uword anglez repeat { - c64.TIME_LO=0 + cbm.TIME_LO=0 rotate_vertices(msb(anglex), msb(angley), msb(anglez)) position_sprites() anglex-=500 @@ -93,9 +93,9 @@ main { anglez+=452 txt.plot(0,0) txt.print("3d cube! (sprites) ") - txt.print_ub(c64.TIME_LO) + txt.print_ub(cbm.TIME_LO) txt.print(" jiffies/fr = ") - txt.print_ub(60/c64.TIME_LO) + txt.print_ub(60/cbm.TIME_LO) txt.print(" fps") ; test_stack.test() diff --git a/examples/cube3d.p8 b/examples/cube3d.p8 index f0b7756b5..96945e45b 100644 --- a/examples/cube3d.p8 +++ b/examples/cube3d.p8 @@ -30,11 +30,11 @@ main { anglez+=907 txt.plot(0,0) txt.print("3d cube! ") - txt.print_ub(c64.TIME_LO) + txt.print_ub(cbm.TIME_LO) txt.print(" jiffies/fr = ") - txt.print_ub(60/c64.TIME_LO) + txt.print_ub(60/cbm.TIME_LO) txt.print(" fps") - c64.TIME_LO=0 + cbm.TIME_LO=0 ; test_stack.test() } diff --git a/examples/cx16/bdmusic.p8 b/examples/cx16/bdmusic.p8 index 075c080de..c1531cb4e 100644 --- a/examples/cx16/bdmusic.p8 +++ b/examples/cx16/bdmusic.p8 @@ -7,7 +7,7 @@ main { sub explosion() { ; this subroutine is not used but it is an example of how to make a sound effect using the psg library! psg.silent() - cx16.set_irq(&psg.envelopes_irq, true) + sys.set_irq(&psg.envelopes_irq, true) psg.voice(0, psg.LEFT, 0, psg.NOISE, 0) psg.voice(1, psg.RIGHT, 0, psg.NOISE, 0) psg.freq(0, 1000) @@ -16,7 +16,7 @@ main { psg.envelope(1, 63, 80, 0, 6) sys.wait(100) psg.silent() - cx16.restore_irq() + sys.restore_irq() } sub sweeping() { @@ -53,13 +53,13 @@ main { sub start() { txt.print("will play the music from boulderdash,\nmade in 1984 by peter liepa.\npress enter to start: ") - void c64.CHRIN() + void cbm.CHRIN() txt.clear_screen() psg.silent() psg.voice(0, psg.LEFT, 63, psg.TRIANGLE, 0) psg.voice(1, psg.RIGHT, 63, psg.TRIANGLE, 0) - cx16.set_irq(&psg.envelopes_irq, true) + sys.set_irq(&psg.envelopes_irq, true) repeat { uword note diff --git a/examples/cx16/bobs.p8 b/examples/cx16/bobs.p8 index cf1f7c30e..b99d9c141 100644 --- a/examples/cx16/bobs.p8 +++ b/examples/cx16/bobs.p8 @@ -38,7 +38,7 @@ main { palette.set_color(0, $000) palette.set_color(1, $af8) - cx16.set_rasterirq(&irq, 340) ; time it so that the page flip at the end occurs near the bottom of the screen to avoid tearing + sys.set_rasterirq(&irq, 340) ; time it so that the page flip at the end occurs near the bottom of the screen to avoid tearing repeat { ; don't exit diff --git a/examples/cx16/colorbars.p8 b/examples/cx16/colorbars.p8 index eb1adc0b5..8c99fcd7c 100644 --- a/examples/cx16/colorbars.p8 +++ b/examples/cx16/colorbars.p8 @@ -21,7 +21,7 @@ main { txt.print("random gradients") irq.make_new_gradient() - cx16.set_rasterirq(&irq.irqhandler, irq.top_scanline) + sys.set_rasterirq(&irq.irqhandler, irq.top_scanline) repeat { } @@ -65,9 +65,7 @@ irq { color_ix = blinds_start_ix } - - - cx16.set_rasterline(next_irq_line) + sys.set_rasterline(next_irq_line) } sub make_new_gradient() { diff --git a/examples/cx16/datetime.p8 b/examples/cx16/datetime.p8 index 7a064a11e..c3df10e4b 100644 --- a/examples/cx16/datetime.p8 +++ b/examples/cx16/datetime.p8 @@ -21,7 +21,7 @@ main { txt.nl() txt.nl() - uword jiffies = c64.RDTIM16() + uword jiffies = cbm.RDTIM16() txt.print_uw(jiffies) } } diff --git a/examples/cx16/diskspeed.p8 b/examples/cx16/diskspeed.p8 index c5d8a2657..035f72104 100644 --- a/examples/cx16/diskspeed.p8 +++ b/examples/cx16/diskspeed.p8 @@ -31,10 +31,10 @@ main { txt.print("\n\nwriting 64kb using save") batchtotaltime = 0 repeat REPEATS { - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) void diskio.save(8, "@:benchmark.dat", $100, 32768) void diskio.save(8, "@:benchmark.dat", $100, 32768) - batchtotaltime += c64.RDTIM16() + batchtotaltime += cbm.RDTIM16() txt.chrout('.') } print_speed(batchtotaltime) @@ -43,12 +43,12 @@ main { batchtotaltime = 0 repeat REPEATS { if diskio.f_open_w(8, "@:benchmark.dat") { - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) repeat 65536/256 { if not diskio.f_write(buffer, 256) sys.exit(1) } - batchtotaltime += c64.RDTIM16() + batchtotaltime += cbm.RDTIM16() diskio.f_close_w() } txt.chrout('.') @@ -58,10 +58,10 @@ main { txt.print("\nreading 64kb using load into hiram") batchtotaltime = 0 repeat REPEATS { - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) if not cx16diskio.load(8, "benchmark.dat", 4, $a000) sys.exit(1) - batchtotaltime += c64.RDTIM16() + batchtotaltime += cbm.RDTIM16() txt.chrout('.') } print_speed(batchtotaltime) @@ -69,10 +69,10 @@ main { txt.print("\nreading 64kb using vload into videoram") batchtotaltime = 0 repeat REPEATS { - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) if not cx16diskio.vload("benchmark.dat", 8, 0, $0000) sys.exit(1) - batchtotaltime += c64.RDTIM16() + batchtotaltime += cbm.RDTIM16() txt.chrout('.') } print_speed(batchtotaltime) @@ -81,12 +81,12 @@ main { batchtotaltime = 0 repeat REPEATS { if diskio.f_open(8, "benchmark.dat") { - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) repeat 65536/255 { if not diskio.f_read(buffer, 255) sys.exit(1) } - batchtotaltime += c64.RDTIM16() + batchtotaltime += cbm.RDTIM16() diskio.f_close() } txt.chrout('.') @@ -97,12 +97,12 @@ main { batchtotaltime = 0 repeat REPEATS { if diskio.f_open(8, "benchmark.dat") { - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) repeat 65536/255 { if not cx16diskio.f_read(buffer, 255) sys.exit(1) } - batchtotaltime += c64.RDTIM16() + batchtotaltime += cbm.RDTIM16() diskio.f_close() } txt.chrout('.') diff --git a/examples/cx16/kefrenbars.p8 b/examples/cx16/kefrenbars.p8 index b00b7cb06..16f9ea5c6 100644 --- a/examples/cx16/kefrenbars.p8 +++ b/examples/cx16/kefrenbars.p8 @@ -24,7 +24,7 @@ main { palette.set_rgb(&colors, len(colors)) gfx2.screen_mode(4) ; lores 256 colors cx16.VERA_DC_VSCALE = 0 ; display trick spoiler.......: stretch 1 line of display all the way to the bottom - cx16.set_rasterirq(&irq.irqhandler, 0) + sys.set_rasterirq(&irq.irqhandler, 0) repeat { ; don't exit @@ -60,6 +60,6 @@ irq { gfx2.next_pixels(pixels, len(pixels)) } - cx16.set_rasterline(next_irq_line) + sys.set_rasterline(next_irq_line) } } diff --git a/examples/cx16/mandelbrot-gfx-colors.p8 b/examples/cx16/mandelbrot-gfx-colors.p8 index 57ed0610a..e26493ae5 100644 --- a/examples/cx16/mandelbrot-gfx-colors.p8 +++ b/examples/cx16/mandelbrot-gfx-colors.p8 @@ -78,11 +78,11 @@ main { void cx16.clock_get_date_time() txt.plot(33, 12) if lsb(cx16.r2) < 10 - c64.CHROUT('0') + txt.chrout('0') txt.print_ub(lsb(cx16.r2)) - c64.CHROUT(':') + txt.chrout(':') if msb(cx16.r2) < 10 - c64.CHROUT('0') + txt.chrout('0') txt.print_ub(msb(cx16.r2)) } } diff --git a/examples/cx16/multipalette.p8 b/examples/cx16/multipalette.p8 index 29ad52c40..3726f8c44 100644 --- a/examples/cx16/multipalette.p8 +++ b/examples/cx16/multipalette.p8 @@ -30,7 +30,7 @@ main { palette.set_color(0, 0) palette.set_color(16, 0) - cx16.set_rasterirq(&irq.irqhandler, 0) + sys.set_rasterirq(&irq.irqhandler, 0) repeat { ; don't exit @@ -402,7 +402,7 @@ irq { phase = 0 } - cx16.set_rasterline(next_rasterline) + sys.set_rasterline(next_rasterline) ; ; uword[16] colors1 = 0 diff --git a/examples/cx16/pcmaudio/play-adpcm.p8 b/examples/cx16/pcmaudio/play-adpcm.p8 index 7ac48d361..a40380cb8 100644 --- a/examples/cx16/pcmaudio/play-adpcm.p8 +++ b/examples/cx16/pcmaudio/play-adpcm.p8 @@ -42,7 +42,7 @@ main { txt.print_uw(vera_rate_hz) txt.print("\n(b)enchmark or (p)layback? ") - when c64.CHRIN() { + when cbm.CHRIN() { 'b' -> benchmark() 'p' -> playback() } @@ -63,7 +63,7 @@ main { nibblesptr = &wavdata.wav_data + wavfile.data_offset txt.print("\ndecoding all blocks...\n") - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) repeat num_adpcm_blocks { adpcm.init(peekw(nibblesptr), @(nibblesptr+2)) nibblesptr += 4 @@ -75,7 +75,7 @@ main { } } const float REFRESH_RATE = 25.0e6/(525.0*800) ; Vera VGA refresh rate is not precisely 60 hz! - float duration_secs = (c64.RDTIM16() as float) / REFRESH_RATE + float duration_secs = (cbm.RDTIM16() as float) / REFRESH_RATE floats.print_f(duration_secs) txt.print(" seconds (approx)\n") const float PCM_WORDS_PER_BLOCK = 1 + 252*2 diff --git a/examples/cx16/rasterbars.p8 b/examples/cx16/rasterbars.p8 index 4f2930698..b224d668b 100644 --- a/examples/cx16/rasterbars.p8 +++ b/examples/cx16/rasterbars.p8 @@ -16,7 +16,7 @@ main { txt.plot(14,14) txt.print("raster bars!") - cx16.set_rasterirq(&irq.irqhandler, 0) + sys.set_rasterirq(&irq.irqhandler, 0) repeat { ; don't exit @@ -56,6 +56,6 @@ irq { palette.set_color(0, c) - cx16.set_rasterline(next_irq_line) + sys.set_rasterline(next_irq_line) } } diff --git a/examples/cx16/tehtriz.p8 b/examples/cx16/tehtriz.p8 index ce2d679cb..f8df0fceb 100644 --- a/examples/cx16/tehtriz.p8 +++ b/examples/cx16/tehtriz.p8 @@ -66,9 +66,9 @@ waitkey: if ticks_since_previous_move==0 ticks_since_previous_move=255 - ubyte time_lo = lsb(c64.RDTIM16()) + ubyte time_lo = lsb(cbm.RDTIM16()) if time_lo>=(60-4*speedlevel) { - c64.SETTIM(0,0,0) + cbm.SETTIM(0,0,0) drawBlock(xpos, ypos, true) ; hide block if blocklogic.noCollision(xpos, ypos+1) { @@ -95,7 +95,7 @@ waitkey: ; test_stack.test() } - ubyte key=c64.GETIN() + ubyte key=cbm.GETIN() keypress(key) joystick(cx16.joystick_get2(1)) @@ -310,26 +310,26 @@ waitkey: sub gameOver() { sound.gameover() txt.plot(7, 7) - c64.CHROUT('U') + txt.chrout('U') txt.print("────────────────────────") - c64.CHROUT('I') + txt.chrout('I') txt.plot(7, 8) txt.print("│*** g a m e o v e r ***│") txt.plot(7, 9) - c64.CHROUT('J') + txt.chrout('J') txt.print("────────────────────────") - c64.CHROUT('K') + txt.chrout('K') txt.plot(7, 18) - c64.CHROUT('U') + txt.chrout('U') txt.print("────────────────────────") - c64.CHROUT('I') + txt.chrout('I') txt.plot(7, 19) txt.print("│ f1/start for new game │") txt.plot(7, 20) - c64.CHROUT('J') + txt.chrout('J') txt.print("────────────────────────") - c64.CHROUT('K') + txt.chrout('K') ubyte key do { @@ -337,7 +337,7 @@ waitkey: cx16.r0 = cx16.joystick_get2(1) if cx16.r0 & %0000000000010000 == 0 break - key = c64.GETIN() + key = cbm.GETIN() } until key==133 } @@ -363,7 +363,7 @@ waitkey: sub spawnNextBlock() { swapBlock(nextBlock) - nextBlock = (math.rnd() + lsb(c64.RDTIM16())) % 7 + nextBlock = (math.rnd() + lsb(cbm.RDTIM16())) % 7 drawNextBlock() holdingAllowed = true } @@ -679,7 +679,7 @@ sound { sub init() { cx16.vpoke(1, $f9c2, %00111111) ; volume max, no channels psg.silent() - cx16.set_irq(&psg.envelopes_irq, true) + sys.set_irq(&psg.envelopes_irq, true) } sub blockrotate() { diff --git a/examples/cx16/vtui/testvtui.p8 b/examples/cx16/vtui/testvtui.p8 index 707dc9df7..d6bc1db65 100644 --- a/examples/cx16/vtui/testvtui.p8 +++ b/examples/cx16/vtui/testvtui.p8 @@ -60,7 +60,7 @@ main { vtui.print_str2("arrow keys to move!", $61, true) char_loop: - ubyte char = c64.GETIN() + ubyte char = cbm.GETIN() if not char goto char_loop diff --git a/examples/cx16/zsound/play-zsound.p8 b/examples/cx16/zsound/play-zsound.p8 index 3dca74728..8a5f3411d 100644 --- a/examples/cx16/zsound/play-zsound.p8 +++ b/examples/cx16/zsound/play-zsound.p8 @@ -52,7 +52,7 @@ zsound_lib: sub start() { txt.print("zsound demo program!\n") - c64.SETMSG(%10000000) ; enable kernal status messages for load + cbm.SETMSG(%10000000) ; enable kernal status messages for load if not cx16diskio.load_raw(8, "colony.zsm", song_bank, song_address) { txt.print("?can't load\n") return @@ -66,7 +66,7 @@ zsound_lib: ; poke(digi_address+2, digi_bank) ; pokew(digi_address, digi_address+zcm_DIGITAB_size) } - c64.SETMSG(0) + cbm.SETMSG(0) txt.nl() cx16.rambank(song_bank) diff --git a/examples/cx16/zsound/stream-test-zcm.p8 b/examples/cx16/zsound/stream-test-zcm.p8 index b98a02be1..f15470ebc 100644 --- a/examples/cx16/zsound/stream-test-zcm.p8 +++ b/examples/cx16/zsound/stream-test-zcm.p8 @@ -60,7 +60,7 @@ zsound_lib: pcm_init() pcm_trigger_digi(digi_bank, digi_address) - cx16.set_irq(&zsm_playroutine_irq, true) + sys.set_irq(&zsm_playroutine_irq, true) txt.print("\nstreaming from file, playback in irq!\n") uword size = 1 diff --git a/examples/line-circle-txt.p8 b/examples/line-circle-txt.p8 index 00a7ef1f4..bebaec974 100644 --- a/examples/line-circle-txt.p8 +++ b/examples/line-circle-txt.p8 @@ -15,14 +15,14 @@ main { } txt.print("enter for disc:") - void c64.CHRIN() - c64.CHROUT('\n') + void cbm.CHRIN() + txt.nl() txt.clear_screen() disc(20, 12, 12) txt.print("enter for rectangles:") - void c64.CHRIN() - c64.CHROUT('\n') + void cbm.CHRIN() + txt.nl() txt.clear_screen() rect(4, 8, 37, 23, false) diff --git a/examples/mandelbrot.p8 b/examples/mandelbrot.p8 index 1d98afc6f..f7edc22c0 100644 --- a/examples/mandelbrot.p8 +++ b/examples/mandelbrot.p8 @@ -12,7 +12,7 @@ main { sub start() { txt.print("calculating mandelbrot fractal...") - c64.SETTIM(0, 0, 0) + cbm.SETTIM(0, 0, 0) ubyte pixelx ubyte pixely @@ -40,7 +40,7 @@ main { } } - float duration = (c64.RDTIM16() as float) / 60 + float duration = (cbm.RDTIM16() as float) / 60 txt.plot(0, 21) txt.print("finished in ") floats.print_f(duration) diff --git a/examples/maze.p8 b/examples/maze.p8 index b1fad02fd..be3820281 100644 --- a/examples/maze.p8 +++ b/examples/maze.p8 @@ -19,7 +19,7 @@ main { maze.drawStartFinish() txt.print(" enter=new maze") - void c64.CHRIN() + void cbm.CHRIN() } } diff --git a/examples/plasma.p8 b/examples/plasma.p8 index 714d1ab84..937fd69dc 100644 --- a/examples/plasma.p8 +++ b/examples/plasma.p8 @@ -26,7 +26,7 @@ main { makechar() ubyte block = c64.CIA2PRA - ; ubyte v = c64.VMCSB + ; ubyte v = cbm.VMCSB c64.CIA2PRA = (block & $FC) | (lsb(SCREEN1 >> 14) ^ $03) repeat { diff --git a/examples/rasterbars.p8 b/examples/rasterbars.p8 index 51589388e..4dc1b51b3 100644 --- a/examples/rasterbars.p8 +++ b/examples/rasterbars.p8 @@ -5,7 +5,7 @@ main { sub start() { c64.SCROLY &= %11101111 ; blank the screen - c64.set_rasterirq(&irq.irqhandler, 40, false) ; register exclusive raster irq handler + sys.set_rasterirq(&irq.irqhandler, 40, false) ; register exclusive raster irq handler repeat { ; enjoy the moving bars :) diff --git a/examples/sprites.p8 b/examples/sprites.p8 index f5e6e55c2..24b16b944 100644 --- a/examples/sprites.p8 +++ b/examples/sprites.p8 @@ -46,7 +46,7 @@ main { } c64.SPENA = 255 ; enable all sprites - c64.set_rasterirq(&irq.irqhandler, 255, true) ; enable animation + sys.set_rasterirq(&irq.irqhandler, 255, true) ; enable animation } } diff --git a/examples/tehtriz.p8 b/examples/tehtriz.p8 index fc9067e4c..3e0690940 100644 --- a/examples/tehtriz.p8 +++ b/examples/tehtriz.p8 @@ -45,8 +45,8 @@ newgame: spawnNextBlock() waitkey: - if c64.TIME_LO>=(60-4*speedlevel) { - c64.TIME_LO = 0 + if cbm.TIME_LO>=(60-4*speedlevel) { + cbm.TIME_LO = 0 drawBlock(xpos, ypos, 32) ; hide block if blocklogic.noCollision(xpos, ypos+1) { @@ -73,7 +73,7 @@ waitkey: ; test_stack.test() } - ubyte key=c64.GETIN() + ubyte key=cbm.GETIN() if key==0 goto waitkey keypress(key) @@ -228,31 +228,31 @@ waitkey: sub gameOver() { sound.gameover() txt.plot(7, 7) - c64.CHROUT('U') + txt.chrout('U') txt.print("────────────────────────") - c64.CHROUT('I') + txt.chrout('I') txt.plot(7, 8) txt.print("│*** g a m e o v e r ***│") txt.plot(7, 9) - c64.CHROUT('J') + txt.chrout('J') txt.print("────────────────────────") - c64.CHROUT('K') + txt.chrout('K') txt.plot(7, 18) - c64.CHROUT('U') + txt.chrout('U') txt.print("────────────────────────") - c64.CHROUT('I') + txt.chrout('I') txt.plot(7, 19) txt.print("│ f1 for new game │") txt.plot(7, 20) - c64.CHROUT('J') + txt.chrout('J') txt.print("────────────────────────") - c64.CHROUT('K') + txt.chrout('K') ubyte key = 0 while key!=133 { ; endless loop until user presses F1 to restart the game - key = c64.GETIN() + key = cbm.GETIN() } } @@ -268,7 +268,7 @@ waitkey: } sub swapBlock(ubyte newblock) { - c64.TIME_LO = 0 + cbm.TIME_LO = 0 blocklogic.newCurrentBlock(newblock) xpos = startXpos ypos = startYpos diff --git a/examples/textelite.p8 b/examples/textelite.p8 index 8eaaccc44..0febbb749 100644 --- a/examples/textelite.p8 +++ b/examples/textelite.p8 @@ -1039,28 +1039,28 @@ util { ldy #0 ; have we started printing? cmp #'0' beq + - jsr c64.CHROUT + jsr cbm.CHROUT iny + lda conv.uword2decimal.decThousands cmp #'0' bne + cpy #0 beq ++ -+ jsr c64.CHROUT ++ jsr cbm.CHROUT iny + lda conv.uword2decimal.decHundreds cmp #'0' bne + cpy #0 beq ++ -+ jsr c64.CHROUT ++ jsr cbm.CHROUT iny + lda conv.uword2decimal.decTens - jsr c64.CHROUT + jsr cbm.CHROUT lda #'.' - jsr c64.CHROUT + jsr cbm.CHROUT lda conv.uword2decimal.decOnes - jsr c64.CHROUT + jsr cbm.CHROUT rts }} } diff --git a/examples/wizzine.p8 b/examples/wizzine.p8 index 94028e262..00b6ce108 100644 --- a/examples/wizzine.p8 +++ b/examples/wizzine.p8 @@ -38,7 +38,7 @@ main { c64.SPRPTR[i] = $0a00/64 } c64.SPENA = 255 ; enable all sprites - c64.set_rasterirq(&irq.irqhandler, 230, true) ; enable animation + sys.set_rasterirq(&irq.irqhandler, 230, true) ; enable animation } } diff --git a/syntax-files/Vim/prog8_builtins.vim b/syntax-files/Vim/prog8_builtins.vim index cd4e897c1..c1f1f64ee 100644 --- a/syntax-files/Vim/prog8_builtins.vim +++ b/syntax-files/Vim/prog8_builtins.vim @@ -97,18 +97,19 @@ syn match prog8BuiltInFunc "\" " c64/syslib.p8 -syn match prog8BuiltInVar "\" -syn match prog8BuiltInVar "\" -syn match prog8BuiltInVar "\" -syn match prog8BuiltInVar "\" -syn match prog8BuiltInVar "\" -syn match prog8BuiltInVar "\" -syn match prog8BuiltInVar "\" -syn match prog8BuiltInVar "\" -syn match prog8BuiltInVar "\" -syn match prog8BuiltInVar "\" -syn match prog8BuiltInVar "\" -syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" +syn match prog8BuiltInVar "\" syn match prog8BuiltInVar "\" syn match prog8BuiltInVar "\" syn match prog8BuiltInVar "\" @@ -232,58 +233,59 @@ syn match prog8BuiltInVar "\" syn match prog8BuiltInVar "\" syn match prog8BuiltInVar "\" syn match prog8BuiltInVar "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" syn match prog8BuiltInVar "\" syn match prog8BuiltInFunc "\" syn match prog8BuiltInFunc "\"