Fixed up shift demo and cbmiolib.c65
This commit is contained in:
parent
5f25d66aeb
commit
033767fb91
2 changed files with 37 additions and 37 deletions
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#INCLUDE <c64start.c65>
|
||||
#INCLUDE <c64defs.c65>
|
||||
#PRAGMA _P_REMOVE_UNUSED 1
|
||||
#INCLUDE <cbmiolib.c65>
|
||||
|
||||
#PRAGMA _P_USE_CBM_STRINGS 1
|
||||
|
|
|
|||
|
|
@ -17,31 +17,29 @@
|
|||
|
||||
GOTO lib_cbmio_skip
|
||||
|
||||
WORD lib_cbmio_to_txtptr
|
||||
FUNC lib_cbmio_print ( lib_cbmio_to_txtptr )
|
||||
FUNC lib_cbmio_print ( {WORD strptr} )
|
||||
//On c64 we "borrow" the undocumented "print zero-terminated string" routine
|
||||
#IFDEF MACHINE_C64
|
||||
ASM
|
||||
lda lib_cbmio_to_txtptr
|
||||
ldy lib_cbmio_to_txtptr+1
|
||||
lda |strptr|
|
||||
ldy |strptr|+1
|
||||
jsr $ab1e ; strout kernal routine
|
||||
ENDASM
|
||||
#IFEND
|
||||
#IFNDEF MACHINE_C64
|
||||
BYTE lib_cbmio_to_char
|
||||
PEEK lib_cbmio_to_txtptr -> lib_cbmio_to_char
|
||||
WHILE lib_cbmio_to_char
|
||||
GOSUB $ffd2 PASSING lib_cbmio_to_char AS ACC
|
||||
INC lib_cbmio_to_txtptr
|
||||
PEEK lib_cbmio_to_txtptr -> lib_cbmio_to_char
|
||||
BYTE ch
|
||||
ch = PEEK strptr
|
||||
WHILE ch
|
||||
GOSUB $ffd2 PASSING ch AS ACC
|
||||
strptr++
|
||||
ch = PEEK strptr
|
||||
WEND
|
||||
#IFEND
|
||||
FEND
|
||||
|
||||
WORD lib_cbmio_tl_txtptr
|
||||
FUNC lib_cbmio_printlf ( lib_cbmio_tl_txtptr )
|
||||
FUNC lib_cbmio_printlf ( {WORD strptr} )
|
||||
|
||||
CALL lib_cbmio_print ( lib_cbmio_tl_txtptr )
|
||||
CALL lib_cbmio_print ( strptr )
|
||||
CALL lib_cbmio_print ( @lib_cbmio_tl_linefeed )
|
||||
|
||||
FEND
|
||||
|
|
@ -77,18 +75,17 @@ lib_cbmio_text_nullstr
|
|||
ENDASM
|
||||
|
||||
|
||||
BYTE lib_cbmio_hb_value
|
||||
FUNC lib_cbmio_hexoutb ( lib_cbmio_hb_value )
|
||||
FUNC lib_cbmio_hexoutb ( {BYTE value} )
|
||||
ASM
|
||||
;ldy #0
|
||||
;lda (lib_cbmio_ho_varaddress),y
|
||||
lda lib_cbmio_hb_value
|
||||
lda |value|
|
||||
and #$0f
|
||||
tax
|
||||
lda lib_cbmio_ho_hexdigits,x
|
||||
sta lib_cbmio_ho_hextxt+1
|
||||
;lda (lib_cbmio_ho_varaddress),y
|
||||
lda lib_cbmio_hb_value
|
||||
lda |value|
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
|
|
@ -101,33 +98,35 @@ FUNC lib_cbmio_hexoutb ( lib_cbmio_hb_value )
|
|||
|
||||
FEND
|
||||
|
||||
WORD lib_cbmio_lib_cbmio_ho_value
|
||||
FUNC lib_cbmio_hexoutw ( lib_cbmio_lib_cbmio_ho_value )
|
||||
ASM
|
||||
lda lib_cbmio_lib_cbmio_ho_value+1
|
||||
sta lib_cbmio_hb_value
|
||||
jsr lib_cbmio_hexoutb
|
||||
lda lib_cbmio_lib_cbmio_ho_value
|
||||
sta lib_cbmio_hb_value
|
||||
jsr lib_cbmio_hexoutb
|
||||
ENDASM
|
||||
FUNC lib_cbmio_hexoutw ( {WORD value} )
|
||||
BYTE high
|
||||
BYTE low
|
||||
|
||||
// Extract high byte (shift right 8 bits)
|
||||
high = value >> 8
|
||||
|
||||
// Extract low byte (direct assignment takes low byte)
|
||||
low = value
|
||||
|
||||
// Print high byte then low byte (big-endian order)
|
||||
CALL lib_cbmio_hexoutb ( high )
|
||||
CALL lib_cbmio_hexoutb ( low )
|
||||
FEND
|
||||
|
||||
WORD lib_cbmio_i_ptr
|
||||
FUNC lib_cbmio_input ( lib_cbmio_i_ptr )
|
||||
BYTE char
|
||||
FUNC lib_cbmio_input ( {WORD strptr} )
|
||||
BYTE ch
|
||||
|
||||
LET char = 0
|
||||
WHILE char <> 13
|
||||
ch = 0
|
||||
WHILE ch <> 13
|
||||
ASM
|
||||
jsr $ffcf
|
||||
sta |char|
|
||||
sta |ch|
|
||||
ENDASM
|
||||
POKE lib_cbmio_i_ptr WITH char
|
||||
INC lib_cbmio_i_ptr
|
||||
POKE strptr , ch
|
||||
strptr++
|
||||
WEND
|
||||
DEC lib_cbmio_i_ptr //replace ending #13 with #0
|
||||
POKE lib_cbmio_i_ptr WITH 0
|
||||
strptr-- //replace ending #13 with #0
|
||||
POKE strptr , 0
|
||||
FEND
|
||||
|
||||
ASM
|
||||
|
|
|
|||
Loading…
Reference in a new issue