mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
Merge branch 'master' into multi-assign
# Conflicts: # examples/test.p8
This commit is contained in:
commit
a3ef8f814b
@ -32,6 +32,17 @@ diskio {
|
||||
cbm.CHKOUT(WRITE_IO_CHANNEL)
|
||||
}
|
||||
|
||||
sub fastmode(ubyte mode) {
|
||||
; -- set fast serial mode (0=none, 1=auto_tx, 2=fast writes, 3=both) for the SD card
|
||||
list_filename[0] = 'u'
|
||||
list_filename[1] = '0'
|
||||
list_filename[2] = '>'
|
||||
list_filename[3] = 'b'
|
||||
list_filename[4] = mode | $30
|
||||
list_filename[5] = 0
|
||||
send_command(list_filename)
|
||||
}
|
||||
|
||||
sub directory() -> bool {
|
||||
; -- Prints the directory contents to the screen. Returns success.
|
||||
|
||||
|
@ -136,14 +136,12 @@ asmsub FREADUY (ubyte value @Y) {
|
||||
}
|
||||
|
||||
asmsub parse(str value @AY) -> float @FAC1 {
|
||||
; -- parse a string value of a number to float in FAC1
|
||||
; warning: on older <R47 kernals it uses an internal BASIC routine that is ROM version dependent,
|
||||
; ($deb6 is inside the routine for VAL at $deb3) See basic.sym from x16-rom
|
||||
; TODO once ROM v47 is released, all the workarounds here can be removed. But probably keep the kernal VAL_1 existance check
|
||||
; -- Parse a string value of a number to float in FAC1.
|
||||
; Requires kernal R47 or newer! (depends on val_1 working)
|
||||
%asm {{
|
||||
ldx VAL_1
|
||||
cpx #$4c ; is there an implementation in VAL_1? (test for JMP)
|
||||
bne + ; no, do it ourselves
|
||||
bne _borked ; no, print error message
|
||||
pha ; yes, count the length and call rom VAL_1.
|
||||
phy
|
||||
jsr prog8_lib.strlen
|
||||
@ -151,15 +149,7 @@ asmsub parse(str value @AY) -> float @FAC1 {
|
||||
ply
|
||||
plx
|
||||
jmp VAL_1
|
||||
+ sta $a9 ; 'index' variable
|
||||
sty $aa
|
||||
jsr prog8_lib.strlen
|
||||
lda $deb6
|
||||
cmp #$d0 ; sanity check for kernal routine correct
|
||||
bne +
|
||||
tya
|
||||
jmp $deb6 ; kernal version dependent...
|
||||
+ ; print error message if routine is borked in kernal, and exit program
|
||||
_borked
|
||||
ldy #0
|
||||
- lda _msg,y
|
||||
beq +
|
||||
@ -168,7 +158,7 @@ asmsub parse(str value @AY) -> float @FAC1 {
|
||||
bne -
|
||||
+ jmp sys.exit
|
||||
|
||||
_msg .text 13,"?val kaputt",13,0
|
||||
_msg .text 13,"?rom 47+ required for val1",13,0
|
||||
}}
|
||||
}
|
||||
|
||||
|
@ -425,6 +425,9 @@ romsub $ff1d = FB_move_pixels(uword sx @R0, uword sy @R1, uword tx @R2, uword ty
|
||||
romsub $FEBA = BSAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) clobbers (X, Y) -> bool @ Pc, ubyte @ A ; like cbm.SAVE, but omits the 2-byte prg header
|
||||
romsub $fec6 = i2c_read_byte(ubyte device @X, ubyte offset @Y) clobbers (X,Y) -> ubyte @A, bool @Pc
|
||||
romsub $fec9 = i2c_write_byte(ubyte device @X, ubyte offset @Y, ubyte data @A) clobbers (A,X,Y) -> bool @Pc
|
||||
romsub $feb4 = i2c_batch_read(ubyte device @X, uword buffer @R0, uword length @R1, bool advance @Pc) clobbers(A,Y) -> bool @Pc
|
||||
romsub $feb7 = i2c_batch_write(ubyte device @X, uword buffer @R0, uword length @R1, bool advance @Pc) clobbers(A,Y) -> bool @Pc
|
||||
|
||||
romsub $fef0 = sprite_set_image(uword pixels @R0, uword mask @R1, ubyte bpp @R2, ubyte number @A, ubyte width @X, ubyte height @Y, bool apply_mask @Pc) clobbers(A,X,Y) -> bool @Pc
|
||||
romsub $fef3 = sprite_set_position(uword x @R0, uword y @R1, ubyte number @A) clobbers(A,X,Y)
|
||||
romsub $fee4 = memory_fill(uword address @R0, uword num_bytes @R1, ubyte value @A) clobbers(A,X,Y)
|
||||
@ -437,6 +440,8 @@ romsub $fee1 = console_get_char() clobbers(X,Y) -> ubyte @A
|
||||
romsub $fed8 = console_put_image(uword pointer @R0, uword width @R1, uword height @R2) clobbers(A,X,Y)
|
||||
romsub $fed5 = console_set_paging_message(uword msgptr @R0) clobbers(A,X,Y)
|
||||
romsub $fecf = entropy_get() -> ubyte @A, ubyte @X, ubyte @Y
|
||||
;; romsub $fea8 = extapi16(ubyte callnumber @A) clobbers (A,X,Y) ; not useful yet because is for 65816 cpu
|
||||
romsub $feab = extapi(ubyte callnumber @A) clobbers (A,X,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
|
||||
@ -524,6 +529,27 @@ romsub $C099 = ym_getatten(ubyte channel @A) clobbers(Y) -> ubyte @X
|
||||
romsub $C09C = ym_getpan(ubyte channel @A) clobbers(Y) -> ubyte @X
|
||||
romsub $C0A5 = ym_get_chip_type() clobbers(X) -> ubyte @A
|
||||
|
||||
; extapi call numbers
|
||||
const ubyte EXTAPI_clear_status = $01
|
||||
const ubyte EXTAPI_getlfs = $02
|
||||
const ubyte EXTAPI_mouse_sprite_offset = $03
|
||||
const ubyte EXTAPI_joystick_ps2_keycodes = $04
|
||||
const ubyte EXTAPI_iso_cursor_char = $05
|
||||
const ubyte EXTAPI_ps2kbd_typematic = $06
|
||||
const ubyte EXTAPI_pfkey = $07
|
||||
const ubyte EXTAPI_ps2data_fetch = $08
|
||||
const ubyte EXTAPI_ps2data_raw = $09
|
||||
const ubyte EXTAPI_cursor_blink = $0A
|
||||
const ubyte EXTAPI_led_update = $0B
|
||||
const ubyte EXTAPI_mouse_set_position = $0C
|
||||
|
||||
; extapi16 call numbers
|
||||
const ubyte EXTAPI16_test = $00
|
||||
const ubyte EXTAPI16_stack_push = $01
|
||||
const ubyte EXTAPI16_stack_pop = $02
|
||||
const ubyte EXTAPI16_stack_enter_kernal_stack = $03
|
||||
const ubyte EXTAPI16_stack_leave_kernal_stack = $04
|
||||
|
||||
|
||||
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)
|
||||
@ -564,6 +590,52 @@ asmsub mouse_pos() clobbers(X) -> ubyte @A {
|
||||
}}
|
||||
}
|
||||
|
||||
; shims for the kernal routines called via the extapi call:
|
||||
|
||||
asmsub mouse_set_pos(uword xpos @R0, uword ypos @R1) clobbers(X) {
|
||||
; -- sets the mouse sprite position
|
||||
%asm {{
|
||||
ldx #cx16.r0L
|
||||
lda #EXTAPI_mouse_set_position
|
||||
jmp cx16.extapi
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub mouse_set_sprite_offset(word xoffset @R0, word yoffset @R1) clobbers(A,X,Y) {
|
||||
%asm {{
|
||||
clc
|
||||
lda #EXTAPI_mouse_sprite_offset
|
||||
jmp cx16.extapi
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub mouse_get_sprite_offset() clobbers(A,X,Y) -> word @R0, word @R1 {
|
||||
%asm {{
|
||||
sec
|
||||
lda #EXTAPI_mouse_sprite_offset
|
||||
jmp cx16.extapi
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub getlfs() -> ubyte @X, ubyte @A, ubyte @Y {
|
||||
; -- return the result of the last call to SETLFS: A=logical, X=device, Y=secondary.
|
||||
%asm {{
|
||||
lda #EXTAPI_mouse_set_position
|
||||
jmp cx16.extapi
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub iso_cursor_char(ubyte character @X) clobbers(A,X,Y) {
|
||||
; -- set the screen code for the cursor character in ISO mode (the default is $9f).
|
||||
%asm {{
|
||||
clc
|
||||
lda #EXTAPI_iso_cursor_char
|
||||
jmp cx16.extapi
|
||||
}}
|
||||
}
|
||||
|
||||
; TODO : implement shims for the remaining extapi calls.
|
||||
|
||||
|
||||
; ---- end of kernal routines ----
|
||||
|
||||
|
@ -8,7 +8,6 @@ Future Things and Ideas
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Compiler:
|
||||
|
||||
- IR: add TEST instruction to test memory content and set N/Z flags, without affecting any register. Replace all LOADM+CMPI #0 / LOAD #0+LOADM+CMP+BRANCH by this instruction
|
||||
- IR: implement missing operators in AssignmentGen (array shifts etc)
|
||||
- can we support signed % (remainder) somehow?
|
||||
- instead of copy-pasting inline asmsubs, make them into a 64tass macro and use that instead.
|
||||
@ -43,15 +42,15 @@ Compiler:
|
||||
But all library code written in asm uses .proc already..... (textual search/replace when writing the actual asm?)
|
||||
Once new codegen is written that is based on the IR, this point is mostly moot anyway as that will have its own dead code removal on the IR level.
|
||||
- Zig-like try-based error handling where the V flag could indicate error condition? and/or BRK to jump into monitor on failure? (has to set BRK vector for that) But the V flag is also set on certain normal instructions
|
||||
- Zig-like defer to execute a statement/anonymousscope at subroutine exit?
|
||||
- generate WASM to eventually run prog8 on a browser canvas? Use binaryen toolkit and/or my binaryen kotlin library?
|
||||
- split words arrays all()
|
||||
- split words arrays sort()
|
||||
- implement split words arrays all()
|
||||
- implement split words arrays sort()
|
||||
|
||||
|
||||
Libraries:
|
||||
|
||||
- gfx2: add EOR mode support like in monogfx and see PAINT for inspiration. Self modifying code to keep it optimized?
|
||||
- once kernal rom v47 is released, remove most of the workarounds in cx16 floats.parse_f() . Prototype parse routine in examples/cx16/floatparse.p8
|
||||
- fix the problems in atari target, and flesh out its libraries.
|
||||
- c128 target: make syslib more complete (missing kernal routines)?
|
||||
- pet32 target: make syslib more complete (missing kernal routines)?
|
||||
|
@ -9,6 +9,7 @@ main {
|
||||
uword duration
|
||||
ubyte[256] bonkbuffer
|
||||
|
||||
;; diskio.fastmode(1)
|
||||
set_screen_mode()
|
||||
cbm.SETTIM(0,0,0)
|
||||
|
||||
|
@ -8,8 +8,6 @@ main {
|
||||
const ubyte HIRAM_START_BANK = 4
|
||||
uword large = memory("large", 20000, 256)
|
||||
|
||||
bool verify = false
|
||||
|
||||
ubyte[256] buffer = 0 to 255
|
||||
uword @zp buf_ptr
|
||||
|
||||
@ -17,10 +15,11 @@ main {
|
||||
txt.print("\n\ndisk benchmark on drive 8.\n")
|
||||
|
||||
txt.print("with verification? y/n: ")
|
||||
cx16.r0L = cbm.CHRIN()
|
||||
bool verify = cbm.CHRIN()=='y'
|
||||
txt.print("\nfast serial mode r+w? y/n: ")
|
||||
bool fastserial = cbm.CHRIN()=='y'
|
||||
txt.nl()
|
||||
if cx16.r0L=='y' {
|
||||
verify=true
|
||||
if verify {
|
||||
; fill the buffers with random data, and calculate the checksum
|
||||
for cx16.r0 in 0 to 19999 {
|
||||
large[cx16.r0] = math.rnd()
|
||||
@ -33,6 +32,11 @@ main {
|
||||
uword crc32_h = cx16.r15
|
||||
}
|
||||
|
||||
if fastserial
|
||||
diskio.fastmode(3)
|
||||
else
|
||||
diskio.fastmode(0)
|
||||
|
||||
test_save()
|
||||
test_save_blocks()
|
||||
test_load_hiram()
|
||||
|
@ -29,6 +29,7 @@ main {
|
||||
ubyte vera_rate
|
||||
|
||||
sub start() {
|
||||
;; diskio.fastmode(1)
|
||||
txt.print("name of .wav file to play on drive 8: ")
|
||||
while 0==txt.input_chars(MUSIC_FILENAME) {
|
||||
; until user types a name...
|
||||
|
@ -12,6 +12,7 @@ main {
|
||||
str filename = "?"*40
|
||||
|
||||
repeat {
|
||||
;; diskio.fastmode(1)
|
||||
txt.print("\nenter bmx image filename: ")
|
||||
if txt.input_chars(&filename)!=0 {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user