mirror of
https://github.com/irmen/prog8.git
synced 2025-02-16 22:30:46 +00:00
cx16: added cx16.get_program_args() and cx16.set_program_args()
This commit is contained in:
parent
3c77f8a020
commit
344a1b9eb8
@ -1172,6 +1172,47 @@ sub search_x16edit() -> ubyte {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub set_program_args(uword args_ptr, ubyte args_size) {
|
||||||
|
; Set the inter-program arguments.
|
||||||
|
; standardized way to pass arguments between programs is in ram bank 0, address $bf00-$bfff.
|
||||||
|
; see https://github.com/X16Community/x16-docs/blob/master/X16%20Reference%20-%2007%20-%20Memory%20Map.md#bank-0
|
||||||
|
sys.push(getrambank())
|
||||||
|
rambank(0)
|
||||||
|
sys.memcopy(args_ptr, $bf00, args_size)
|
||||||
|
if args_size<255
|
||||||
|
@($bf00+args_size) = 0
|
||||||
|
rambank(sys.pop())
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub get_program_args(uword buffer @R0, ubyte buf_size @R1, bool binary @Pc) {
|
||||||
|
; Retrieve the inter-program arguments. If binary=false, it treats them as a string (stops copying at first zero).
|
||||||
|
; standardized way to pass arguments between programs is in ram bank 0, address $bf00-$bfff.
|
||||||
|
; see https://github.com/X16Community/x16-docs/blob/master/X16%20Reference%20-%2007%20-%20Memory%20Map.md#bank-0
|
||||||
|
%asm {{
|
||||||
|
lda #0
|
||||||
|
rol a
|
||||||
|
sta P8ZP_SCRATCH_REG
|
||||||
|
lda $00
|
||||||
|
pha
|
||||||
|
stz $00
|
||||||
|
stz P8ZP_SCRATCH_W1
|
||||||
|
lda #$bf
|
||||||
|
sta P8ZP_SCRATCH_W1+1
|
||||||
|
ldy #0
|
||||||
|
- lda (P8ZP_SCRATCH_W1),y
|
||||||
|
sta (cx16.r0),y
|
||||||
|
beq +
|
||||||
|
_continue iny
|
||||||
|
cpy cx16.r1L ; max size?
|
||||||
|
bne -
|
||||||
|
beq ++
|
||||||
|
+ lda P8ZP_SCRATCH_REG ; binary?
|
||||||
|
bne _continue
|
||||||
|
+ pla
|
||||||
|
sta $00
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sys {
|
sys {
|
||||||
|
@ -106,7 +106,6 @@ sys (part of syslib)
|
|||||||
including the uninitialized ones ("BSS" variables) and the uninitialized memory blocks reserved by the `memory()` function.
|
including the uninitialized ones ("BSS" variables) and the uninitialized memory blocks reserved by the `memory()` function.
|
||||||
Can be used to load dynamic data after the program, instead of hardcoding something.
|
Can be used to load dynamic data after the program, instead of hardcoding something.
|
||||||
|
|
||||||
|
|
||||||
``wait (uword jiffies)``
|
``wait (uword jiffies)``
|
||||||
wait approximately the given number of jiffies (1/60th seconds)
|
wait approximately the given number of jiffies (1/60th seconds)
|
||||||
Note: the regular system irq handler has run for this to work as it depends on the system jiffy clock.
|
Note: the regular system irq handler has run for this to work as it depends on the system jiffy clock.
|
||||||
@ -527,9 +526,13 @@ The compiler needs it for various built-in system routines.
|
|||||||
cx16
|
cx16
|
||||||
----
|
----
|
||||||
This is available on *all targets*, it is always imported as part of syslib.
|
This is available on *all targets*, it is always imported as part of syslib.
|
||||||
On the Commander X16 this module contains a whole bunch of things specific to that machine.
|
On the Commander X16 this module contains a *whole bunch* of things specific to that machine.
|
||||||
|
It's way too much to include here, you have to study the
|
||||||
|
`source code <https://github.com/irmen/prog8/tree/master/compiler/res/prog8lib/cx16/syslib.p8>`_
|
||||||
|
to see what is there.
|
||||||
|
|
||||||
On the other targets, it only contains the definition of the 16 memory mapped virtual registers
|
On the other targets, it only contains the definition of the 16 memory mapped virtual registers
|
||||||
(cx16.r0 - cx16.r15) and the following two utility routines:
|
(cx16.r0 - cx16.r15) and the following utility routines:
|
||||||
|
|
||||||
``save_virtual_registers()``
|
``save_virtual_registers()``
|
||||||
save the values of all 16 virtual registers r0 - r15 in a buffer. Might be useful in an IRQ handler to avoid clobbering them.
|
save the values of all 16 virtual registers r0 - r15 in a buffer. Might be useful in an IRQ handler to avoid clobbering them.
|
||||||
@ -537,6 +540,10 @@ On the other targets, it only contains the definition of the 16 memory mapped vi
|
|||||||
``restore_virtual_registers()``
|
``restore_virtual_registers()``
|
||||||
restore the values of all 16 virtual registers r0 - r15 from the buffer. Might be useful in an IRQ handler to avoid clobbering them.
|
restore the values of all 16 virtual registers r0 - r15 from the buffer. Might be useful in an IRQ handler to avoid clobbering them.
|
||||||
|
|
||||||
|
``cpu_is_65816()``
|
||||||
|
Returns true if the CPU in the computer is a 65816, false otherwise (6502 cpu).
|
||||||
|
|
||||||
|
|
||||||
bmx (cx16 only)
|
bmx (cx16 only)
|
||||||
----------------
|
----------------
|
||||||
Routines to load and save "BMX" files, the CommanderX16 bitmap file format.
|
Routines to load and save "BMX" files, the CommanderX16 bitmap file format.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user