mirror of
https://github.com/irmen/prog8.git
synced 2025-01-26 19:30:59 +00:00
added "emudbg" library (cx16 only) to interface with the emulator
This commit is contained in:
parent
a289b32053
commit
e505bf9ccf
58
compiler/res/prog8lib/cx16/emudbg.p8
Normal file
58
compiler/res/prog8lib/cx16/emudbg.p8
Normal file
@ -0,0 +1,58 @@
|
||||
; Emulator debug interface.
|
||||
; Docs: https://github.com/X16Community/x16-emulator#debug-io-registers
|
||||
|
||||
emudbg {
|
||||
|
||||
const uword EMU_BASE = $9fb0
|
||||
|
||||
&ubyte EMU_DBG_HOTKEY_ENABLED = EMU_BASE + 0
|
||||
&ubyte EMU_LOG_VIDEO = EMU_BASE + 1
|
||||
&ubyte EMU_LOG_KEYBOARD = EMU_BASE + 2
|
||||
&ubyte EMU_ECHO_MODE = EMU_BASE + 3
|
||||
&ubyte EMU_SAVE_ON_EXIT = EMU_BASE + 4
|
||||
&ubyte EMU_RECORD_GIF = EMU_BASE + 5
|
||||
&ubyte EMU_RECORD_WAV = EMU_BASE + 6
|
||||
&ubyte EMU_CMDKEYS_DISABLED = EMU_BASE + 7
|
||||
&ubyte EMU_CPUCLK_L = EMU_BASE + 8 ; write: reset cpu clock to 0
|
||||
&ubyte EMU_CPUCLK_M = EMU_BASE + 9 ; write: outputs "User debug 1: $xx"
|
||||
&ubyte EMU_CPUCLK_H = EMU_BASE + 10 ; write: outputs "User debug 2: $xx"
|
||||
&ubyte EMU_CPUCLK_U = EMU_BASE + 11 ; write: outputs as character to console
|
||||
; 12 is unused for now
|
||||
&ubyte EMU_KEYMAP = EMU_BASE + 13
|
||||
&ubyte EMU_EMU_DETECT1 = EMU_BASE + 14
|
||||
&ubyte EMU_EMU_DETECT2 = EMU_BASE + 15
|
||||
|
||||
sub is_emulator() -> bool {
|
||||
return EMU_EMU_DETECT1=='1' and EMU_EMU_DETECT2=='6'
|
||||
}
|
||||
|
||||
asmsub console_write(str isoString @R0) clobbers(Y) {
|
||||
%asm {{
|
||||
ldy #0
|
||||
- lda (cx16.r0),y
|
||||
beq +
|
||||
sta p8_EMU_CPUCLK_U
|
||||
iny
|
||||
bne -
|
||||
+
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub console_chrout(ubyte char @A) {
|
||||
%asm {{
|
||||
sta p8_EMU_CPUCLK_U
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub console_value1(ubyte value @A) {
|
||||
%asm {{
|
||||
sta p8_EMU_CPUCLK_M
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub console_value2(ubyte value @A) {
|
||||
%asm {{
|
||||
sta p8_EMU_CPUCLK_H
|
||||
}}
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@
|
||||
; https://docs.google.com/document/d/1q34uWOiM3Be2pnaHRVgSdHySI-qsiQWPTo_gfE54PTg/edit
|
||||
|
||||
verafx {
|
||||
%option no_symbol_prefixing
|
||||
|
||||
sub clear(ubyte vbank, uword vaddr, ubyte data, uword amountof32bits) {
|
||||
; use cached 4-byte write to quickly clear a portion of the video memory to a given byte value
|
||||
|
@ -435,6 +435,18 @@ On the other targets, it only contains the definition of the 16 memory mapped vi
|
||||
restore the values of all 16 virtual registers r0 - r15 from the buffer. Might be useful in an IRQ handler to avoid clobbering them.
|
||||
|
||||
|
||||
emudbg (cx16 only)
|
||||
-------------------
|
||||
X16Emu Emulator debug routines, for Cx16 only.
|
||||
Allows you to interface with the emulator's debug routines/registers.
|
||||
There's stuff like ``is_emulator`` to detect if running in the emulator,
|
||||
and ``console_write`` to write a (iso) string to the emulator's console (stdout) etc.
|
||||
|
||||
Read the `source code <https://github.com/irmen/prog8/tree/master/compiler/res/prog8lib/cx16/emudbg.p8>`_
|
||||
to see what's in there.
|
||||
Information about the exposed debug registers is in the `emulator's documentation <https://github.com/X16Community/x16-emulator#debug-io-registers>`_.
|
||||
|
||||
|
||||
|
||||
gfx2 (cx16 only)
|
||||
-----------------
|
||||
|
@ -1,7 +1,8 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- add some routines to use the x16's emulator special addresses such as the stdout print register?
|
||||
- add verafx transparent writes enable/disable routines
|
||||
- add %option verafxmuls in block to enable transparent verafx muls use for that block only + add warning message to docs to not use it it in prg AND irq code
|
||||
- '>>=' can be used as an operator in an expression?? should only be augmented assignment!
|
||||
|
||||
- [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....
|
||||
|
@ -1,102 +1,21 @@
|
||||
%import gfx2
|
||||
%import textio
|
||||
;%import math
|
||||
%import verafx
|
||||
%import emudbg
|
||||
%zeropage basicsafe
|
||||
%option no_sysinit
|
||||
|
||||
main {
|
||||
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.print_ub(emudbg.is_emulator())
|
||||
txt.nl()
|
||||
emudbg.console_value1(123)
|
||||
emudbg.console_value2(222)
|
||||
for cx16.r0L in iso:"Hello debug console!\n"
|
||||
emudbg.console_chrout(cx16.r0L)
|
||||
|
||||
gfx2.screen_mode(1)
|
||||
|
||||
cbm.SETTIM(0,0,0)
|
||||
repeat 255 {
|
||||
gfx2.clear_screen()
|
||||
}
|
||||
uword time1 = cbm.RDTIM16()
|
||||
|
||||
cbm.SETTIM(0,0,0)
|
||||
repeat 255 {
|
||||
verafx.clear(0, 0, %10101010, 2400)
|
||||
}
|
||||
uword time2 = cbm.RDTIM16()
|
||||
|
||||
gfx2.screen_mode(0)
|
||||
txt.print_uw(time1)
|
||||
txt.spc()
|
||||
txt.print_uw(time2)
|
||||
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()
|
||||
emudbg.console_write(iso:"Hello another message!\n")
|
||||
|
||||
emudbg.EMU_DBG_HOTKEY_ENABLED=false
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user