Retaining all of the changes made to save bytes to support the 3x8 keyboard, the d7=1 Key Pressed flag, etc, it comes in at 122 bytes with four functions ... GO and CR are at the locations indicated by the datasheet, PageForward next to CR and RV at the opposite side to Go.
And addr0 is back in the IRQ/BRK vector spot, so the option to serve as a crude break point monitor is restored.
Code: Select all
code
org $ff80 ; +16
LED_PATTERNS:
db 0b00111111 ;0
db 0b00000110 ;1
db 0b01011011 ;2
db 0b01001111 ;3
db 0b01100110 ;4
db 0b01101101 ;5
db 0b01111101 ;6
db 0b00000111 ;7
db 0b01111111 ;8
db 0b01101111 ;9
db 0b01011111 ;a
db 0b00111100 ;b
db 0b00101000 ;c
db 0b01011110 ;d
db 0b01111101 ;e
db 0b01110001 ;f
exec: jmp addr0 ; +3
start: ; +6
; Set base address, this is also "review"
lda #>addr0
sta W+1
stz W ; start address addr0, page aligned
loop_main: ; +19
; current state to leds
; put W and (W) into leds
; [x][x][x][x][x][x][ ][ ]
;
ldx #0
lda W+1
jsr to_leds
lda W
jsr to_leds
lda (W)
jsr to_leds
; Initialize the display count
; Need to drive six leds for display
; The sixth is redundant for 4x5 "keyboard"
; Top two leds are never driven, so dark
ldy #5
loop_digit: ; +10
; for each LED digit (right to left)...
lda leds,y
sta led_addr,y ; display bit pattern
lda keys
; d7 = NOR( row1, row2, row3)
bmi loop_99 ; no key pressed
; +10
; do stuff to sort out the key value
; a hex key if below smallest command code
; in circuit diagram, this is the GO key
cmp #KEY_GO
bmi loop_hex ; enter hex value
beq exec ; return addr0 to review
cmp #KEY_PF ; test 2nd largest command code
beq loop_pf ; increment W high byte
bpl start ; reset W to addr0
; +8
; remaining special key is return
inc W
bne loop_90
loop_pf:
inc W+1
bra loop_90
loop_hex: ; +14
; else shuffle key value into (W)
; In this version, d7=NOT(Press)
; so d7 clear if hex key
pha
lda (W)
asl a
asl a
asl a
asl a
sta (W)
pla
ora (W)
sta (W)
loop_90: ; +4
; wait for key to be released
; this will cause display glitch, but...
lda keys
bmi loop_90
loop_99: ; +5
dey ; underflows after 0th column
bpl loop_digit
bra loop_main ; will reset Y to 5
to_leds: ; +23
; unpack byte into two adjacent LED patterns
; x has character position
pha
and #$0f ; low nibble
tay
lda LED_PATTERNS,y ; index into the patterns
sta leds+1,x ; and output into the LED array
pla
lsr a
lsr a
lsr a
lsr a ; high nibble
tay
lda LED_PATTERNS,y
sta leds,x ; this byte goes on the left
inx
inx
rts
; 6 byte gap
org $fffc ; +4
dw start
dw start ; BRK restarts micro-monitor
In the micro-monitor role, if it is desired that it not be "blind" to the zero page and stack page, there is this modification which fits into the available six bytes:
Code: Select all
restart: ; +6
; Reset base address to ZP unless already ZP
lda #0
cmp W+1
bne restart_zp
start: ; +6
; Set base address, this is also "review stage 2"
lda #>addr0
restart_zp:
In this version, "RV" from anywhere outside of the zero page starts at $0000, but from inside the zero page is start at addr0.
Or if simpler mode free command keys are preferred, restart goes to $0000, as two taps of page forward would take you to $0200, but the previous one takes you straight to $0200 in another tap of PreView even after having a look at what your code has been doing in its page zero variables:
Code: Select all
restart: ; +4
; Reset base address to ZP
lda #0
bra restart_zp
start: ; +6
; Set base address
lda #>addr0
restart_zp:
If they are to be available as desolder & resolder patches, it is between the end of the the exec jump and "start" that the spare space would go, and the patch would also involve patching the two vectors at the end.
However, since the branch to restart is via a "BPL", the easiest to "diode patch" version is to start with:
Code: Select all
restart: ; +4
; Restore base address to addr0
bmi start
lda #0 ; {code if bmi patched to bpl}
bra restart_zp ; {set base address to $0000.}
start: ; +6
; Set base address
lda #>addr0
restart_zp:
... where the "bmi" opcode is $30, %00110000, so that if it is desired for ReView to start at $0000 instead, patch on bit to:
Code: Select all
restart: ; +4
; Reset base address to ZP
bpl start
lda #0
bra restart_zp
start: ; +6
; Set base address
lda #>addr0
restart_zp:
... where the "bpl" opcode is $10, %00010000.
For programmable memory that erases to $FF and are programmed by resetting the bits that should be 0, that would work as a programmable memory patch as well as a DROM patch. Mind, in the context of the DROM, there may be a way to install a push button switch to make that patch a pushbutton setting.