CHRIN for MEGA65 - code complete, but needs bugfixing

This commit is contained in:
FeralChild64 committed 2020-08-27 22:44:42 +02:00
1 parent 0d07074b20
commit dee452d352
6 files changed
+80 -24

No files matched your search

+31 -11
View File
@@ -8,10 +8,8 @@
m65_chrin_keyboard: // XXX connnect this function to Kernal
// Preserve .X, .Y and .Z registers
// Preserve .Z register
phx
phy
phz
// FALLTROUGH
@@ -24,8 +22,6 @@ m65_chrin_keyboard_repeat:
lda CRSW
beq m65_chrin_keyboard_read
// XXX implement
// We have input waiting at [M65__SCRINPUT]+CRSW
// When CRSW = INDX, then we return a carriage return and clear the flag
@@ -50,9 +46,9 @@ m65_chrin_keyboard_empty_line:
m65_chrin_keyboard_end:
ldx XSAV
plz
ply
plx
clc
rts
@@ -67,7 +63,14 @@ m65_chrin_keyboard_not_end_of_input:
m65_chrin_keyboard_return_byte:
// XXX implement
jsr m65_helper_scrlpnt_chrin
tya
taz
lda_lp (M65_LPNT_SCR), z
jsr screen_check_toggle_quote
jsr screen_code_to_petscii
jmp_8 m65_chrin_keyboard_end
@@ -113,10 +116,9 @@ m65_chrin_keyboard_enter:
adc M65_TXTROW_OFF+1
sta M65__SCRINPUT+1
// XXX for windowed mode add current column too
// Retrieve first byte which is not space
jsr m65_helper_scrlpnt_chrin
ldy INDX
iny
@@ -124,13 +126,30 @@ m65_chrin_keyboard_enter:
m65_chrin_enter_loop:
// Skip spaces at the end of line
dey
bmi m65_chrin_keyboard_empty_line
// XXX implement
tya
taz
lda_lp (M65_LPNT_SCR), z
cmp #$20
beq m65_chrin_enter_loop
iny
sty INDX
rts
// XXX add windowed mode support here - correct INDX and M65__SCRINPUT
// Set mark informing that we are returning a line
ldy #$01
sty CRSW
// Clear quote mode mark
dey
sty QTSW
// Return first char of line
jmp_8 m65_chrin_keyboard_return_byte // branch always
m65_chrkin_keyboard_not_enter:
@@ -148,3 +167,4 @@ m65_chrkin_keyboard_not_enter:
jsr CHROUT
jsr pop_keyboard_buffer
jmp m65_chrin_keyboard_repeat
@@ -33,15 +33,11 @@ m65_helper_scrlpnt_color:
rts
m65_helper_scrlpnt_to_screen:
// Change M65_LPNT_SCR to point to screen memory (when it points to color memory)
lda M65_SCRSEG+1
sta M65_LPNT_SCR+3
lda M65_SCRSEG+0
sta M65_LPNT_SCR+2
clc
lda M65_SCRBASE+0
adc M65_LPNT_SCR+0
@@ -50,4 +46,26 @@ m65_helper_scrlpnt_to_screen:
adc M65_LPNT_SCR+1
sta M65_LPNT_SCR+1
// FALLTROUGH
m65_helper_scrlpnt_to_screen_hi:
lda M65_SCRSEG+1
sta M65_LPNT_SCR+3
lda M65_SCRSEG+0
sta M65_LPNT_SCR+2
rts
m65_helper_scrlpnt_chrin:
// Prepare the pointer for CHRIN
lda M65__SCRINPUT+0
sta M65_LPNT_SCR+0
lda M65__SCRINPUT+1
sta M65_LPNT_SCR+1
jmp_8 m65_helper_scrlpnt_to_screen_hi