This is how I adopted VTL02c for the Kowalski emulator. The disabled section (commented out) section is the original apple 2 memory map:
Code:
;-----------------------------------------------------;
; Equates for a 48K+ Apple 2 (original, +, e, c, gs)
;ESC = 27 ; "Cancel current input line" key
;BS = 8 ; "Delete last keypress" key
;OP_OR = '!' ; Bit-wise OR operator
;linbuf = $0200 ; input line buffer
;prgm = $0800 ; VTL02B program grows from here
;himem = $8000 ; ... up to the top of user RAM
;vtl02c = $8000 ; interpreter cold entry point
; (warm entry point is startok)
;KBD = $c000 ; 128 + keypress if waiting
;KEYIN = $fd0c ; apple monitor keyin routine
;COUT = $fded ; apple monitor charout routine
;-----------------------------------------------------;
; Equates for the Kowalski 6502 simulator
ESC = 27 ; "Cancel current input line" key
BS = 8 ; "Delete last keypress" key
OP_OR = '|' ; Bit-wise OR operator
linbuf = $0200 ; input line buffer
prgm = $0400 ; VTL02B program grows from here
himem = $F000 ; ... up to the top of user RAM
vtl02c = $FC00 ; interpreter cold entry point
; (warm entry point is startok)
io_area = $f000 ;configure simulator terminal I/O
acia_tx = io_area+1 ;acia tx data register
acia_rx = io_area+4 ;acia rx data register
;=====================================================;
The zero page area is fixed from $80 - $ff.
Since in the Kowalski simulator console I/O changes from being supported by the Monitor ROM to raw hardware (a simulated ACIA), you must also change the I/O subroutines (inkey, inch, outch):
Code:
;============ Original I/O subroutines ===============;
;-----------------------------------------------------;
; Check for user keypress and return with (cc) if none
; is pending. Otherwise, fall through to inch
; and return with (cs).
; 6 bytes
;inkey:
; lda KBD ; is there a keypress waiting?
; asl
; bcc outrts ; no: return with (cc)
; - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Read key from stdin into a, echo, (cs)
; drop stack and abort to "OK" prompt if ctrl-C
; 16 bytes
;inch:
; sty dolr ; save y reg
; jsr KEYIN ; get a char from keyboard
; ldy dolr ; restore y reg
; and #$7f ; strip apple's hi-bit
; cmp #$03 ; ctrl-C?
; bne outch ; no: echo to terminal
; jmp start ; yes: abort to "OK" prompt
; - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Print ASCII char in a to stdout, (cs)
; 9 bytes
;outch:
; pha ; save original char
; ora #$80 ; apples prefer "high" ASCII
; jsr COUT ; emit char via apple monitor
; pla ; restore original char
; sec ; (by contract with callers)
;outrts:
; rts
;-----------------------------------------------------;
;========== 2m5 SBC emulator I/O subroutines ============;
;-----------------------------------------------------;
; Check for user keypress and return if none
; is pending. Otherwise, check for ctrl-C and
; return after next keypress.
;
inkey:
lda acia_rx ; Is there a character waiting?
beq inkeyr ; no: return
cmp #3 ; is ctrl-c
beq istart ; yes: abort to OK prompt
inkeyp:
lda acia_rx ; pause until next key
beq inkeyp
cmp #3 ; is ctrl-c
beq istart ; yes: abort to OK prompt
inkeyr:
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Read key from stdin into a, echo, (cs)
; Dump stack and abort to "OK" prompt if ctrl-C
; 16 bytes
inch:
lda acia_rx ; get character from rx register
beq inch ; wait for character !=0
cmp #10 ; remove line feed to allow paste
beq inch ; in the Kowalski I/O window
inch2:
cmp #$03 ; ctrl-C?
bne outch ; no: echo to terminal
istart:
jmp start ; yes: abort to "OK" prompt
; - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Print ascii char in a to stdout, (cs)
; 16 bytes
outch:
cmp #13 ; add line feed to carriage return
bne skip_cr
lda #10
sta acia_tx
lda #13
skip_cr:
sta acia_tx ; emit char via transmit register
sec ; (by contract with callers)
rts
;-----------------------------------------------------;
Assembler options at the beginning of the source code may have to be changed or must be set manually depending on the assembler used:
Code:
; In the Kowalski 6502 simulator some of the options
; below must be set manually.
;
; .lf vtl02ca2.lst (set listfile in menu:
; Simulator->Options->Assembler)
; .cr 6502
.opt Proc6502
;
; to run with I/O set terminal active:
; Menu or Key
; Simulator->Options->Simulator [Ctrl-E]
; Simulator->Assemble [F7]
; Simulator->Debugger [F6]
; Simulator->Run [F5]
; View->Input/output [Alt-5]
;
; .tf vtl02ca2.obj,ap1 (optional save output to
; file: File->Save Code)
There are some slight syntax differences to the original assembler.
Referring to the low (none to <) or high (/ to >) byte of a word.
Directives (2 letters to full word)
The whole source for the Kowalski simulator is here:
https://github.com/Klaus2m5/VTL02/blob/ ... l02ca2.65s