diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt index e08b7ca87..376bfec7a 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt @@ -183,7 +183,7 @@ internal class BuiltinFunctionsAsmGen(private val program: PtProgram, asmgen.out(" sta (+)+0 | sty (+)+1") asmgen.assignExpressionToRegister(fcall.args[2], RegisterOrPair.AY) // uword argument asmgen.out(""" - jsr cx16.jsrfar + jsr cx16.JSRFAR + .word 0 + .byte 0""") // note that by convention the values in A+Y registers are now the return value of the call. diff --git a/compiler/res/prog8lib/cx16/diskio.p8 b/compiler/res/prog8lib/cx16/diskio.p8 index a01e6aaeb..ec2eb255e 100644 --- a/compiler/res/prog8lib/cx16/diskio.p8 +++ b/compiler/res/prog8lib/cx16/diskio.p8 @@ -301,22 +301,22 @@ close_end: sub f_read(uword bufferpointer, uword num_bytes) -> uword { ; -- read from the currently open file, up to the given number of bytes. ; returns the actual number of bytes read. (checks for End-of-file and error conditions) - ; NOTE: cannot be used to load into VRAM. Use vload() or call cx16.macptr() yourself with the vera data register as address. + ; NOTE: cannot be used to load into VRAM. Use vload() or call cx16.MACPTR() yourself with the vera data register as address. if not iteration_in_progress or not num_bytes return 0 reset_read_channel() list_blocks = 0 ; we reuse this variable for the total number of bytes read - ; commander X16 supports fast block-read via macptr() kernal call + ; commander X16 supports fast block-read via MACPTR() kernal call uword readsize while num_bytes { readsize = 255 if num_bytes uword { ; -- read the full contents of the file, returns number of bytes read. - ; NOTE: cannot be used to load into VRAM. Use vload() or call cx16.macptr() yourself with the vera data register as address. + ; NOTE: cannot be used to load into VRAM. Use vload() or call cx16.MACPTR() yourself with the vera data register as address. if not iteration_in_progress return 0 diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 3d2c4bea4..7c333d898 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -331,17 +331,16 @@ cx16 { ; spelling of the names is taken from the Commander X-16 rom sources ; supported C128 additions -romsub $ff4a = close_all(ubyte device @A) clobbers(A,X,Y) -romsub $ff59 = lkupla(ubyte la @A) clobbers(A,X,Y) -romsub $ff5c = lkupsa(ubyte sa @Y) clobbers(A,X,Y) +romsub $ff4a = CLOSE_ALL(ubyte device @A) clobbers(A,X,Y) +romsub $ff59 = LKUPLA(ubyte la @A) clobbers(A,X,Y) +romsub $ff5c = LKUPSA(ubyte sa @Y) clobbers(A,X,Y) romsub $ff5f = screen_mode(ubyte mode @A, bool getCurrent @Pc) clobbers(X, Y) -> ubyte @A, bool @Pc ; note: X,Y size result is not supported, use SCREEN or get_screen_mode routine for that romsub $ff62 = screen_set_charset(ubyte charset @A, uword charsetptr @XY) clobbers(A,X,Y) ; incompatible with C128 dlchr() ; not yet supported: romsub $ff65 = pfkey() clobbers(A,X,Y) -romsub $ff6e = jsrfar() ; following word = address to call, byte after that=rom/ram bank it is in +romsub $ff6e = JSRFAR() ; following word = address to call, byte after that=rom/ram bank it is in romsub $ff74 = fetch(ubyte bank @X, ubyte index @Y) clobbers(X) -> ubyte @A romsub $ff77 = stash(ubyte data @A, ubyte bank @X, ubyte index @Y) clobbers(X) -romsub $ff7a = cmpare(ubyte data @A, ubyte bank @X, ubyte index @Y) clobbers(X) -romsub $ff7d = primm() +romsub $ff7d = PRIMM() ; It's not documented what registers are clobbered, so we assume the worst for all following kernal routines...: @@ -395,7 +394,8 @@ romsub $fed5 = console_set_paging_message(uword msgptr @R0) clobbers(A,X,Y) romsub $fecf = entropy_get() -> ubyte @A, ubyte @X, ubyte @Y romsub $fecc = monitor() clobbers(A,X,Y) -romsub $ff44 = macptr(ubyte length @A, uword buffer @XY, bool dontAdvance @Pc) clobbers(A) -> bool @Pc, uword @XY +romsub $ff44 = MACPTR(ubyte length @A, uword buffer @XY, bool dontAdvance @Pc) clobbers(A) -> bool @Pc, uword @XY +romsub $feb1 = MCIOUT(ubyte length @A, uword buffer @XY, bool dontAdvance @Pc) clobbers(A) -> bool @Pc, uword @XY romsub $ff47 = enter_basic(bool cold_or_warm @Pc) clobbers(A,X,Y) romsub $ff4d = clock_set_date_time(uword yearmonth @R0, uword dayhours @R1, uword minsecs @R2, ubyte jiffies @R3) clobbers(A, X, Y) romsub $ff50 = clock_get_date_time() clobbers(A, X, Y) -> uword @R0, uword @R1, uword @R2, ubyte @R3 ; result registers see clock_set_date_time() diff --git a/docs/source/programming.rst b/docs/source/programming.rst index 54abdbaf0..cec47bb7f 100644 --- a/docs/source/programming.rst +++ b/docs/source/programming.rst @@ -937,7 +937,7 @@ memory (name, size, alignment) You can only treat it as a pointer or use it in inline assembly. callfar (bank, address, argumentword) -> uword ; NOTE: specific to cx16 target for now - Calls an assembly routine in another bank on the Commander X16 (using its ``jsrfar`` routine) + Calls an assembly routine in another bank on the Commander X16 (using its ``JSRFAR`` routine) Be aware that ram OR rom bank may be changed depending on the address it jumps to! The argumentword will be loaded into the A+Y registers before calling the routine. The uword value that the routine returns in the A+Y registers, will be returned. diff --git a/docs/source/todo.rst b/docs/source/todo.rst index e270e981e..31100cf30 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,6 +1,8 @@ TODO ==== +- make the adpcm example able to decode and play stereo music. + - [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 .... - [on branch: ir-less-branch-opcodes] IR: reduce the number of branch instructions such as BEQ, BEQR, etc (gradually), replace with CMP(I) + status branch instruction - IR: reduce amount of CMP/CMPI after instructions that set the status bits correctly (LOADs? INC? etc), but only after setting the status bits is verified! @@ -53,6 +55,8 @@ Compiler: Libraries: +- gfx2 cs_innerloop640() extend number of bytes cleared, and use vera fx cached writes +- gfx2 horizontal_line and vertical_line: use vera fx cached writes - port monogfx, gf2, graphics to the vm - use verafx transparent writes to speed up pixel plotting in gfx2 and monogfx modules (avoids read/mask/write) - fix the problems in atari target, and flesh out its libraries. diff --git a/examples/cx16/chunkedfile/mcf.p8 b/examples/cx16/chunkedfile/mcf.p8 index bd337d26f..8bbfcf83b 100644 --- a/examples/cx16/chunkedfile/mcf.p8 +++ b/examples/cx16/chunkedfile/mcf.p8 @@ -181,7 +181,7 @@ processchunk_call jsr $ffff ; modified ubyte readsize = 255 if msb(size)==0 readsize = lsb(size) - cx16.r2 = cx16.macptr(readsize, bonkbuffer, false) ; can't macptr directly to bonk ram + cx16.r2 = cx16.MACPTR(readsize, bonkbuffer, false) ; can't MACPTR directly to bonk ram cx16.rombank(bonk) sys.memcopy(bonkbuffer, cx16.r3, cx16.r2) ; copy to bonk ram cx16.rombank(orig_rom_bank) @@ -192,9 +192,9 @@ processchunk_call jsr $ffff ; modified sub readblock(uword size, uword address, bool dontAdvance) -> uword { if msb(size)>=2 - return cx16.macptr(0, address, dontAdvance) ; read 512 bytes + return cx16.MACPTR(0, address, dontAdvance) ; read 512 bytes if msb(size) - return cx16.macptr(255, address, dontAdvance) ; read 255 bytes - return cx16.macptr(lsb(size), address, dontAdvance) ; read remaining number of bytes + return cx16.MACPTR(255, address, dontAdvance) ; read 255 bytes + return cx16.MACPTR(lsb(size), address, dontAdvance) ; read remaining number of bytes } } diff --git a/examples/test.p8 b/examples/test.p8 index 3f3146773..108a3a747 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,83 +1,18 @@ -%import diskio -%import textio -;%import math -;%import verafx -%zeropage basicsafe -%option no_sysinit - main { - %option verafxmuls - sub start() { - word w1 = -123 - word w2 = 222 - ubyte b2 = 222 - byte sb2 = 111 - txt.print_w(w1*w2) - txt.nl() - txt.print_w(w1*222) - txt.nl() - w1 = -123 - w1 *= 222 - txt.print_w(w1) - txt.nl() - w1 = -123 - w1 *= w2 - txt.print_w(w1) - txt.nl() - w1 = -123 - w1 *= (w2-1) - txt.print_w(w1) - txt.nl() - w1 = -123 - w1 *= b2 - txt.print_w(w1) - txt.nl() - w1 = -123 - w1 *= sb2 - txt.print_w(w1) - txt.nl() - -; txt.print_uw(math.mul16_last_upper()) -; txt.nl() -; uword value1=5678 -; uword value2=9999 -; uword result = value1*value2 -; uword upper16 = math.mul16_last_upper() -; txt.print_uw(result) -; txt.spc() -; txt.print_uw(upper16) -; txt.nl() - - -; const word MULTIPLIER = 431 -; -; ; verify results: -; for value in -50 to 50 { -; if value*MULTIPLIER != verafx.muls(value, MULTIPLIER) { -; txt.print("verafx muls error\n") -; sys.exit(1) -; } -; } -; -; -; word value -; txt.print("verafx muls...") -; cbm.SETTIM(0,0,0) -; for value in -50 to 50 { -; repeat 250 void verafx.muls(value, MULTIPLIER) -; } -; txt.print_uw(cbm.RDTIM16()) -; txt.nl() -; -; txt.print("6502 muls...") -; cbm.SETTIM(0,0,0) -; for value in -50 to 50 { -; repeat 250 cx16.r0s = value*MULTIPLIER -; } -; txt.print_uw(cbm.RDTIM16()) -; txt.nl() - + cx16.r1H = %00000001 ; enable auto-indent + cx16.r2L = 4 + cx16.r2H = 80 + cx16.r3L = 8 + cx16.r3H = 11<<4 | 7; background_color<<4 | text_color + cx16.r4 = 0 + cx16.r1L = 0 + cx16.rombank($d) + %asm {{ + ldx #2 + ldy #64 + jmp $c006 + }} } }