mirror of
https://github.com/uffejakobsen/acme.git
synced 2025-04-20 07:37:08 +00:00
added some misc example files and fixed kernal docs in lib
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@309 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
5629c58010
commit
125d525b7d
@ -55,8 +55,8 @@ lib_cbm_kernal_a = 1
|
||||
k_stop = $ffe1 ; check STOP key
|
||||
k_getin = $ffe4:k_get = $ffe4 ; get input byte (not the same as $ffcf, see note* below)
|
||||
; A is result byte
|
||||
; X is preserved
|
||||
; Y gets clobbered by tape access (preserved by disk access)
|
||||
; X gets clobbered by keyboard access (preserved by disk access)
|
||||
; Y gets clobbered by keyboard/tape access (preserved by disk access)
|
||||
k_clall = $ffe7
|
||||
k_udtim = $ffea
|
||||
; pet rom stops here!?
|
||||
|
@ -2,10 +2,13 @@ ASSEMBLER6502 = acme
|
||||
AS_FLAGS = -v9 -Wtype-mismatch
|
||||
RM = rm
|
||||
|
||||
PROGS = ddrv128.prg ddrv64.prg macedit.o trigono.o
|
||||
PROGS = c64misc.prg ddrv128.prg ddrv64.prg macedit.o trigono.o
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
c64misc.prg: c64misc.a
|
||||
$(ASSEMBLER6502) $(AS_FLAGS) --outfile c64misc.prg --format cbm c64misc.a
|
||||
|
||||
ddrv128.prg: ddrv.a
|
||||
$(ASSEMBLER6502) $(AS_FLAGS) --outfile ddrv128.prg --format cbm -DSYSTEM=128 ddrv.a
|
||||
|
||||
|
18
examples/c64misc.a
Normal file
18
examples/c64misc.a
Normal file
@ -0,0 +1,18 @@
|
||||
;ACME 0.97
|
||||
|
||||
*=$0801
|
||||
!to "c64example.prg", cbm
|
||||
!src "misc/basicstub.a"
|
||||
jsr primm : !pet "\renter name: ", 0
|
||||
jsr minibuf0
|
||||
lda #0 ; terminate input
|
||||
sta minibuf_buf, x
|
||||
jsr primm : !pet "\ryou entered: <", 0
|
||||
lda #>minibuf_buf
|
||||
ldy #<minibuf_buf
|
||||
jsr print_string_AAYY
|
||||
jsr primm : !pet ">\rbye!\r", 0
|
||||
rts
|
||||
!src "misc/minibuf0.a"
|
||||
!src "misc/primm.a"
|
||||
!src "misc/print_string.a"
|
BIN
examples/c64misc.exp
Normal file
BIN
examples/c64misc.exp
Normal file
Binary file not shown.
16
examples/misc/basicstub.a
Normal file
16
examples/misc/basicstub.a
Normal file
@ -0,0 +1,16 @@
|
||||
;ACME 0.97
|
||||
|
||||
;* = $0801 ; c64
|
||||
;* = $1001 ; c16/+4
|
||||
;* = $1c01 ; c128
|
||||
!wo line2, 2020 ; link pointer and line number
|
||||
!by $9e, ' ' ; "sys "
|
||||
!by '0' + entry % 10000 / 1000
|
||||
!by '0' + entry % 1000 / 100
|
||||
!by '0' + entry % 100 / 10
|
||||
!by '0' + entry % 10
|
||||
!pet ':', $8f, " this is a comment!" ; ":rem "
|
||||
!by 0 ; line terminator
|
||||
line2 !wo 0 ; program terminator
|
||||
|
||||
entry ; the BASIC stub jumps here
|
92
examples/misc/minibuf0.a
Normal file
92
examples/misc/minibuf0.a
Normal file
@ -0,0 +1,92 @@
|
||||
;ACME 0.97
|
||||
; string entry with cursor, but user cannot destroy the screen.
|
||||
|
||||
!src <cbm/petscii.a>
|
||||
|
||||
; some zeropage/system/kernal addresses used:
|
||||
!address {
|
||||
z_chars_in_keybuf = $c6
|
||||
z_cursor_disable = $cc ; zero means interrupt handles cursor
|
||||
z_char_under_cursor = $ce
|
||||
z_cursor_is_visible = $cf
|
||||
z_quote_mode = $d4
|
||||
sys_color_under_cursor = $0287
|
||||
k_write_to_screen = $ea13 ; A = screencode, X = color
|
||||
k_chrout = $ffd2
|
||||
k_getin = $ffe4
|
||||
}
|
||||
|
||||
!zone minibuf0
|
||||
|
||||
; config:
|
||||
.MINIBUF_MAXSIZE = 16 ; maximum length user can type
|
||||
!addr minibuf_buf = $200 ; where the actual buffer space is
|
||||
; $200 is the system's input buffer.
|
||||
; you could also use $100, that's what is used when numbers are
|
||||
; converted to their string representations.
|
||||
|
||||
; actual code:
|
||||
|
||||
minibuf0 ; call this to get user input
|
||||
; on entry: place the cursor where you want it to be
|
||||
; on exit: X = number of characters in buffer (not terminated)
|
||||
ldx #0 ; clear buffer
|
||||
beq @next
|
||||
;always
|
||||
|
||||
---- ; check for DEL key
|
||||
cpy #petscii_DEL
|
||||
bne +
|
||||
txa ; if cursor is at start, do nothing!
|
||||
beq @next
|
||||
dex ; "remove" char from buffer
|
||||
; and now remove it from screen:
|
||||
lda #0 ; clear quote flag so LEFT works
|
||||
sta z_quote_mode
|
||||
lda #petscii_LEFT
|
||||
jsr k_chrout
|
||||
lda #' '
|
||||
jsr k_chrout
|
||||
lda #petscii_LEFT
|
||||
jmp @output
|
||||
+ ; check for other control characters
|
||||
tya
|
||||
and #%.##.....
|
||||
beq @next ; control character, so ignore
|
||||
; printable:
|
||||
tya ; restore byte
|
||||
; if you want to filter out unwanted characters, add your code here!
|
||||
; try to add byte to buffer
|
||||
cpx #.MINIBUF_MAXSIZE ; check for overrun
|
||||
beq @next ; buffer is full, so ignore
|
||||
; add byte to buf
|
||||
sta minibuf_buf, x
|
||||
inx ; fix content length
|
||||
@output jsr k_chrout ; put on screen
|
||||
@next ; wait for key with flashing cursor
|
||||
- lda z_chars_in_keybuf
|
||||
sta z_cursor_disable ; disable cursor on last iteration
|
||||
beq -
|
||||
; if there is an artefact, remove it
|
||||
lsr z_cursor_is_visible ; check + clear flag in one go
|
||||
txa ; remember length
|
||||
pha
|
||||
bcc +
|
||||
; restore char under cursor
|
||||
lda z_char_under_cursor
|
||||
ldx sys_color_under_cursor
|
||||
jsr k_write_to_screen ; clobbers y
|
||||
+ ; get character
|
||||
jsr k_getin ; returns A, clobbers X and Y
|
||||
tay ; into Y
|
||||
pla ; restore length
|
||||
tax
|
||||
; check for RETURN
|
||||
cpy #petscii_CR
|
||||
bne ----
|
||||
; X holds number of characters in buffer
|
||||
; if you want the string to be terminated, add these two instructions
|
||||
; (but don't forget to make sure the buffer is large enough):
|
||||
;lda #0
|
||||
;sta minibuf_buf, x
|
||||
rts
|
31
examples/misc/primm.a
Normal file
31
examples/misc/primm.a
Normal file
@ -0,0 +1,31 @@
|
||||
;ACME 0.97
|
||||
|
||||
; zp variables
|
||||
!addr ptr = $fb
|
||||
|
||||
; kernal
|
||||
!addr k_chrout = $ffd2
|
||||
|
||||
; print immediate - prints zero-terminated string located directly
|
||||
; after calling JSR. returns to opcode following the terminator.
|
||||
primm pla ; get low byte of return address - 1
|
||||
tay ; into Y
|
||||
pla ; get high byte of return address - 1
|
||||
sta ptr + 1 ; to ptr high
|
||||
lda #0 ; and zero ptr low, so "(ptr), y" points before text
|
||||
sta ptr
|
||||
beq @entry
|
||||
;;;
|
||||
--- jsr k_chrout
|
||||
@entry iny
|
||||
bne +
|
||||
; fix high byte
|
||||
inc ptr + 1
|
||||
+ lda (ptr), y
|
||||
bne ---
|
||||
; push updated address onto stack
|
||||
lda ptr + 1
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
rts ; return to caller (after zero-terminated text)
|
27
examples/misc/print_string.a
Normal file
27
examples/misc/print_string.a
Normal file
@ -0,0 +1,27 @@
|
||||
;ACME 0.97
|
||||
|
||||
; zp variables
|
||||
!addr ptr = $fb
|
||||
|
||||
; kernal
|
||||
!addr k_chrout = $ffd2
|
||||
|
||||
; print zero-terminated string
|
||||
print_string_AAYY
|
||||
sta ptr + 1 ; store high byte of pointer
|
||||
lda #0 ; and clear low byte of pointer so we can use "(ptr), y"
|
||||
sta ptr
|
||||
beq +
|
||||
;;;
|
||||
--- jsr k_chrout
|
||||
iny
|
||||
bne +
|
||||
; fix high byte
|
||||
inc ptr + 1
|
||||
+ lda (ptr), y
|
||||
bne ---
|
||||
rts
|
||||
|
||||
!eof
|
||||
There is also a version in the c64 basic rom (strout, $ab1e), but that one
|
||||
stops at double quotes.
|
Loading…
x
Reference in New Issue
Block a user