cx16: fix signature return values of cx16.screen_mode(), add get_screen_mode() and set_screen_mode() convenience routines

This commit is contained in:
Irmen de Jong 2023-07-08 11:37:29 +02:00
parent d26967a87d
commit 4ced8889d3
3 changed files with 62 additions and 3 deletions

View File

@ -328,7 +328,7 @@ cx16 {
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(A, X, Y) -> bool @Pc
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
@ -415,6 +415,23 @@ romsub $C09F = audio_init() clobbers(A,X,Y) -> bool @Pc ; (re)ini
; TODO: add more of the audio routines?
asmsub set_screen_mode(ubyte mode @A) clobbers(A,X,Y) -> bool @Pc {
; -- convenience wrapper for screen_mode() to just set a new mode (and return success)
%asm {{
clc
jmp screen_mode
}}
}
asmsub get_screen_mode() -> byte @A, byte @X, byte @Y {
; -- convenience wrapper for screen_mode() to just get the current mode in A, and size in tiles in X+Y
; this does need a piece of inlined asm to call it ans store the result values if you call this from prog8 code
%asm {{
sec
jmp screen_mode
}}
}
asmsub kbdbuf_clear() {
; -- convenience helper routine to clear the keyboard buffer
%asm {{

View File

@ -1,7 +1,9 @@
TODO
====
- IR: instructions that do type conversion (such as EXT, SZ etc, CONCAT, SGN) should put the result in a DIFFERENT register.
- fix VM print_w
- fix VM abs(byte) it always returns 0
- IR: instructions that do type conversion (SZ etc, CONCAT, SGN) should put the result in a DIFFERENT register.
...

View File

@ -1,7 +1,47 @@
%import palette
%import textio
%zeropage basicsafe
%option no_sysinit
main {
sub start() {
ubyte @shared current = cx16.screen_mode(0, true)
ubyte @shared width
ubyte @shared height
txt.print_ub(current)
txt.nl()
cx16.set_screen_mode(128)
%asm {{
phx
jsr cx16.get_screen_mode
sta p8_current
stx p8_width
sty p8_height
plx
}}
txt.print_ub(current)
txt.spc()
txt.print_ub(width)
txt.spc()
txt.print_ub(height)
txt.nl()
txt.nl()
byte intensity = -25
txt.print_b(intensity)
txt.nl()
txt.print_b(abs(intensity))
intensity = abs(intensity)
txt.nl()
txt.print_b(intensity)
txt.nl()
word intensityw = 2555
txt.print_uw0(12345)
txt.nl()
txt.print_w(intensityw)
txt.nl()
txt.print_w(abs(intensityw))
intensityw = abs(intensityw)
txt.nl()
txt.print_w(intensityw)
}
}