migrated to ACME assembler

commit 145d64aa6e78838ed07cefed372f0ad6a4687e97
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 20 20:16:57 2020 +0200

    ACME adaptation

commit 885209d7822286744ea53232ae7461472a01d5d6
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 20 19:57:25 2020 +0200

    ACME adaptation

commit 334d84486bc603551887e7cbeb59d329f2224cc7
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 20 18:29:15 2020 +0200

    ACME adaptation

commit b5966f49bcd8f0ca79cbec93819a31238924707e
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 20 18:09:31 2020 +0200

    ACME adaptation

commit 786536a93a5eab5e676fca99625b4eb094a554e7
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 20 17:24:48 2020 +0200

    ACME adaptation

commit 704c70dfb1f5d68775d6f3da220803b8a3990f56
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 20 15:07:12 2020 +0200

    ACME adaptation

commit 136874964c9083b375f151475310f9636871fc72
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 20 14:45:14 2020 +0200

    ACME adaptation

commit 8eca0d5700b72d04336e72c5cd3a68e18b85f96d
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 20 14:06:52 2020 +0200

    ACME adaptation

commit 11d29eb7ee318239d782f85498b6d0524624d5c4
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 20 13:56:45 2020 +0200

    ACME apaptation

commit c9b5e5e04cceb92c66bc027e6440bc0f7c5a499f
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 20 13:49:04 2020 +0200

    ACME adaptation

commit f5cc254cbc921f07863807468cb3fe26b410b409
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 20 13:01:18 2020 +0200

    ACME adaptation

commit e135a27bf9c30cc0965379c954564e06406303b1
Author: FeralChild64 <you@example.com>
Date:   Sat Sep 19 21:55:01 2020 +0200

    ACME adaptation

commit e9dfddf90d9e2795e88b7da40ae050d733faeb56
Author: FeralChild64 <you@example.com>
Date:   Sat Sep 19 21:48:47 2020 +0200

    Makefile fix

commit 07030104c65cf5e5beeacf6d629ccb9245e58657
Author: FeralChild64 <you@example.com>
Date:   Sat Sep 19 21:42:00 2020 +0200

    ACME adaptation

commit f824362ee5bcfbffca86c430b57773b2ffd65655
Author: FeralChild64 <you@example.com>
Date:   Sat Sep 19 20:14:56 2020 +0200

    ACME adaptation

commit 3a3c59007dcd4940d89b8669f34ca56b61c25fdf
Author: FeralChild64 <you@example.com>
Date:   Fri Sep 18 21:51:45 2020 +0200

    ACME adaptation

commit 6790ef7bc88a41de2881c69b7524dd4ab8c74b5d
Author: FeralChild64 <you@example.com>
Date:   Fri Sep 18 20:35:23 2020 +0200

    ACME adaptation

commit 38ad18b90e9ec713aa7ca49576b3388ce1733357
Author: FeralChild64 <you@example.com>
Date:   Fri Sep 18 18:46:20 2020 +0200

    ACME adaptation

commit 541340371122a9702f7b2d9771c298223cffd0e9
Author: FeralChild64 <you@example.com>
Date:   Fri Sep 18 16:49:46 2020 +0200

    ACME adaptation

commit 25cfd5e186459be1a260d3eb8cfff767838de370
Author: FeralChild64 <you@example.com>
Date:   Thu Sep 17 20:13:33 2020 +0200

    ACME adaptation

commit f61599444d5b1d03d8fd8e4a6a7c3b85069bedb3
Author: FeralChild64 <you@example.com>
Date:   Thu Sep 17 19:29:23 2020 +0200

    ACME adaptation

commit b290be31ec7bb2e5723607697da1bbc621c84429
Author: FeralChild64 <you@example.com>
Date:   Thu Sep 17 17:20:14 2020 +0200

    ACME adaptation

commit 877be9e856880d98fd4bcb25b42aaaacda9dc463
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 16 21:47:38 2020 +0200

    ACME adaptation

commit bb20edaf85d386e41d5c2f715b745b68fbd3362e
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 16 21:31:30 2020 +0200

    ACME adaptation

commit c5d31bd8685abce37c8e254d15aac20bd1570d9f
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 16 18:40:49 2020 +0200

    ACME adaptation

commit 29349826b38f8a89649171559dc8cf24c560aff1
Author: FeralChild64 <you@example.com>
Date:   Mon Sep 14 23:35:47 2020 +0200

    ACME adaptation

commit 8bcd6a621c4b11766d0cf34f79858ba90a67248e
Author: FeralChild64 <you@example.com>
Date:   Mon Sep 14 22:52:25 2020 +0200

    ACME adaptation

commit e87a69edc2ce4bfcc460c31e08dcc352a985f88d
Author: FeralChild64 <you@example.com>
Date:   Mon Sep 14 22:43:27 2020 +0200

    ACME adaptation

commit f49a097bd52e96d00b866c02bda7121e4543233c
Author: FeralChild64 <you@example.com>
Date:   Mon Sep 14 19:02:07 2020 +0200

    ACME adaptation

commit fa0e9214a633b8e8f867cc70925b390940dcd426
Author: FeralChild64 <you@example.com>
Date:   Mon Sep 14 17:47:19 2020 +0200

    ACME adaptation

commit 1b763b91e7a03e426227129c7f22f0ce57a4c197
Author: FeralChild64 <you@example.com>
Date:   Mon Sep 14 17:17:10 2020 +0200

    ACME adaptation

commit e92a4b57b232cd85eb1e71090b8a89c7c8461ebc
Author: FeralChild64 <you@example.com>
Date:   Mon Sep 14 17:15:37 2020 +0200

    ACME adaptation

commit de3c693e8a7e73ea5289198946058e3240894e6a
Author: FeralChild64 <you@example.com>
Date:   Mon Sep 14 17:10:05 2020 +0200

    ACME adaptation

commit f9bd7ae0f04e932d613be9ed5cb19af9be5d338e
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 13 14:34:44 2020 +0200

    ACME adaptation

commit 694dee52555dbfc2b1f7f452a9671ff51106c057
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 13 14:16:14 2020 +0200

    ACME adaptation

commit 0af2c55edfcd22942d9f25417eb0d35f55b71604
Author: FeralChild64 <you@example.com>
Date:   Fri Sep 11 17:38:09 2020 +0200

    ACME adaptation

commit 2015e17334bd56a1e8a13a5abc098d9c2e7ea44f
Author: FeralChild64 <you@example.com>
Date:   Fri Sep 11 16:46:05 2020 +0200

    ACME adaptation

commit b1e972162798d60f4483cd6cc261e856c20c2c8c
Author: FeralChild64 <you@example.com>
Date:   Fri Sep 11 16:24:31 2020 +0200

    ACME adaptation

commit 9d027e868466901ba53bf074a79ec8cf16273021
Author: FeralChild64 <you@example.com>
Date:   Fri Sep 11 15:04:31 2020 +0200

    ACME adaptation

commit 957186deddd1aa4f3b4f1aa1f421e4239a584e57
Author: FeralChild64 <you@example.com>
Date:   Thu Sep 10 22:49:07 2020 +0200

    ACME adaptation

commit b8060f67a455cfac109f08d96b62c360d693b931
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 23:07:28 2020 +0200

    ACME adaptation

commit e54d004568f44bbfe5c070ef1d7cf3544112e497
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 22:58:20 2020 +0200

    ACME adaptation

commit f90b77f073c5a605cb31c6ee451f65c8a8aff7d8
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 22:12:09 2020 +0200

    ACME adaptation

commit b211bb4afcd9c58fe1f5c92f3007717d611cd531
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 22:01:40 2020 +0200

    ACME adaptation

commit 8d7ea343b07e9e08e5f77f3c414758a6cffd0440
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 21:38:34 2020 +0200

    ACME adaptation

commit 46413eb0d92d6400aba0ff8dfe556e61e8a44d78
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 21:07:47 2020 +0200

    ACME adaptation

commit 9f98f69ecc21f7b74a5eb89e247f5a2c6fcb655d
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 20:05:03 2020 +0200

    ACME adaptation

commit 7bb9f1cadc682c7e0a4a6796739d860d473ca110
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 19:55:12 2020 +0200

    ACME adaptation

commit 5fc115392b5bdca6b56f67ad866b1884d2d2bdf8
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 19:31:10 2020 +0200

    ACME adaptation

commit b7940fc60e568d859df9e3156f6bacc6d685b2cc
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 19:16:09 2020 +0200

    ACME adaptation

commit 56288cb97197561afa0816b29c134ec1190e8eab
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 18:48:23 2020 +0200

    ACME adaptation

commit 10401a60fc7922a53d782120ef6795d889140218
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 16:34:16 2020 +0200

    ACME adaptation

commit 8ce76e4d2b56837a691ae84b1a412a2ae32a157b
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 16:20:44 2020 +0200

    ACME adaptation

commit 33fade899fa6172ea6b5b5f6683bb61f544429fd
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 15:28:46 2020 +0200

    ACME adaptation

commit a416f04734402fcfbc57a933731376df2e0180a1
Author: FeralChild64 <you@example.com>
Date:   Wed Sep 9 12:40:03 2020 +0200

    ACME adaptation

commit f8daee005b1d29f6912723be2ac94bc5fbeb0508
Author: FeralChild64 <you@example.com>
Date:   Mon Sep 7 23:29:54 2020 +0200

    ACME adaptation

commit 83fe6bdd0b08a44fdbfc6eefe323a4b194ccaf5b
Author: FeralChild64 <you@example.com>
Date:   Mon Sep 7 22:23:16 2020 +0200

    ACME adaptation

commit cb1f75620b9c83000a15c9c7f7acefdfee79a979
Author: FeralChild64 <you@example.com>
Date:   Mon Sep 7 19:23:12 2020 +0200

    ACME adaptation

commit e524d517c933ae1f0aeb49764d307fadb4845025
Author: FeralChild64 <you@example.com>
Date:   Sun Sep 6 08:24:25 2020 +0200

    ACME adaptation - replaced comments

commit 2ab572c3a21f4a78a7312d0e684bc11d91d1717a
Author: FeralChild64 <you@example.com>
Date:   Sat Sep 5 17:59:10 2020 +0200

    ACME adaptation - replaced the assembler
This commit is contained in:
FeralChild64 committed 2020-09-20 20:22:36 +02:00
1 parent bfc8291e41
commit c8d255130c
685 files changed
+15835 -16296

No files matched your search

+50 -50
View File
@@ -1,86 +1,86 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 BASIC_0 #TAKE
// #LAYOUT# M65 BASIC_1 #TAKE-FLOAT
// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# M65 BASIC_0 #TAKE
;; #LAYOUT# M65 BASIC_1 #TAKE-FLOAT
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
;; #LAYOUT# * * #IGNORE
//
// Well-known BASIC routine, described in:
//
// - [CM64] Computes Mapping the Commodore 64 - page 95
// - https://www.lemon64.com/forum/viewtopic.php?t=64721&sid=bc400a5a6d404f8f092e4d32a92f5de7
//
;
; Well-known BASIC routine, described in:
;
; - [CM64] Computes Mapping the Commodore 64 - page 95
; - https://www.lemon64.com/forum/viewtopic.php?t=64721&sid=bc400a5a6d404f8f092e4d32a92f5de7
;
LINKPRG:
#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0)
!ifdef SEGMENT_M65_BASIC_0 {
jsr map_BASIC_1
jsr_ind VB1__LINKPRG
jmp map_NORMAL
jsr map_BASIC_1
jsr (VB1__LINKPRG)
jmp map_NORMAL
#else
} else {
// Start by getting pointer to the first line
; Start by getting pointer to the first line
jsr init_oldtxt
linkprg_loop:
// Is the pointer to the end of the program
; Is the pointer to the end of the program
ldy #1
#if ROM_LAYOUT_M65
!ifdef CONFIG_MB_M65 {
jsr peek_via_OLDTXT
#elif CONFIG_MEMORY_MODEL_60K
} else ifdef CONFIG_MEMORY_MODEL_60K {
ldx #<OLDTXT+0
jsr peek_under_roms
cmp #$00
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
jsr peek_under_roms_via_OLDTXT
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
} else { ; CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
}
bne !+
bne @1
// End of program
; End of program
rts
!:
// Now search forward to find the end of the line
// Skip forward pointer and line number
@1:
; Now search forward to find the end of the line
; Skip forward pointer and line number
ldy #4
linkprg_end_of_line_search:
#if ROM_LAYOUT_M65
!ifdef CONFIG_MB_M65 {
jsr peek_via_OLDTXT
#elif CONFIG_MEMORY_MODEL_60K
} else ifdef CONFIG_MEMORY_MODEL_60K {
ldx #<OLDTXT+0
jsr peek_under_roms
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
jsr peek_under_roms_via_OLDTXT
#else // CONFIG_MEMORY_MODEL_38K
} else { ; CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
}
cmp #$00
beq !+
beq @2
// Not yet end of line
; Not yet end of line
iny
bne linkprg_end_of_line_search
// line too long
; line too long
jmp do_STRING_TOO_LONG_error
!:
// Found end of line, so update pointer
@2:
; Found end of line, so update pointer
// First, skip over the $00 char
; First, skip over the $00 char
iny
// Now overwrite the pointer (carefully)
//
; Now overwrite the pointer (carefully)
;
tya
clc
adc OLDTXT+0
@@ -88,27 +88,27 @@ linkprg_end_of_line_search:
php
ldy #0
#if ROM_LAYOUT_M65
!ifdef CONFIG_MB_M65 {
jsr poke_via_OLDTXT
#elif CONFIG_MEMORY_MODEL_60K
} else ifdef CONFIG_MEMORY_MODEL_60K {
ldx #<OLDTXT+0
jsr poke_under_roms
#else
} else {
sta (OLDTXT),y
#endif
}
plp
lda OLDTXT+1
adc #0
ldy #1
#if ROM_LAYOUT_M65
!ifdef CONFIG_MB_M65 {
jsr poke_via_OLDTXT
#elif CONFIG_MEMORY_MODEL_60K
} else ifdef CONFIG_MEMORY_MODEL_60K {
jsr poke_under_roms
#else
} else {
sta (OLDTXT),y
#endif
}
sta OLDTXT+1
pla
@@ -117,4 +117,4 @@ linkprg_end_of_line_search:
jmp linkprg_loop
#endif // ROM layout
} ; ROM layout
+35 -36
View File
@@ -1,46 +1,46 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
//
// Delete the current BASIC line, which is assumed to have already been found with find_line.
// Consists of copying memory down and lline linkage update.
//
;
; Delete the current BASIC line, which is assumed to have already been found with find_line.
; Consists of copying memory down and lline linkage update.
;
delete_line:
// jsr printf
// .text "DELETING LINE AT $"
// .byte $f1,<OLDTXT,>OLDTXT
// .byte $f0,<OLDTXT,>OLDTXT
// .byte $0d,0
; jsr printf
; .text "DELETING LINE AT $"
; .byte $f1,<OLDTXT,>OLDTXT
; .byte $f0,<OLDTXT,>OLDTXT
; .byte $0d,0
// Get address of next line
; Get address of next line
ldy #$00
#if CONFIG_MEMORY_MODEL_60K
!ifdef CONFIG_MEMORY_MODEL_60K {
ldx #<OLDTXT
jsr peek_under_roms
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
jsr peek_under_roms_via_OLDTXT
#else // CONFIG_MEMORY_MODEL_38K
} else { ; CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
}
sta __tokenise_work3
iny
#if CONFIG_MEMORY_MODEL_60K
!ifdef CONFIG_MEMORY_MODEL_60K {
jsr peek_under_roms
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
jsr peek_under_roms_via_OLDTXT
#else // CONFIG_MEMORY_MODEL_38K
} else { ; CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
}
sta __tokenise_work4
// Work out length of this line by looking at the pointer
; Work out length of this line by looking at the pointer
lda __tokenise_work3
sec
sbc OLDTXT+0
@@ -49,30 +49,29 @@ delete_line:
sbc OLDTXT+1
sta __tokenise_work4
// jsr printf
// .text "LINE LENGTH IS $"
// .byte $f0,<__tokenise_work4,>__tokenise_work4
// .byte $f0,<__tokenise_work3,>__tokenise_work3
// .byte $0d,0
; jsr printf
; .text "LINE LENGTH IS $"
; .byte $f0,<__tokenise_work4,>__tokenise_work4
; .byte $f0,<__tokenise_work3,>__tokenise_work3
; .byte $0d,0
lda __tokenise_work4
sbc #0
cmp #$00
beq !+
// Line length is <0 or >255 bytes.
// Either way, things are bad, so abort.
; Line length is <0 or >255 bytes.
; Either way, things are bad, so abort.
jmp do_MEMORY_CORRUPT_error
!:
// Length can now be safely assumed to be in the low
// byte only, i.e., stored in __tokenise_work3
+bne do_MEMORY_CORRUPT_error
; Length can now be safely assumed to be in the low
; byte only, i.e., stored in __tokenise_work3
ldx __tokenise_work3
// Shuffle everything down
; Shuffle everything down
jsr shift_txt_down
// Finish by fixing program linkage and calculating new
; Finish by fixing program linkage and calculating new
jmp update_LINKPRG_VARTAB_do_clr
+30 -31
View File
@@ -1,55 +1,55 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
// Find the BASIC line with number in LINNUM
; Find the BASIC line with number in LINNUM
#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K
!ifndef CONFIG_MEMORY_MODEL_46K_OR_50K {
find_line_from_start:
// Get pointer to start of BASIC text
; Get pointer to start of BASIC text
jsr init_oldtxt
// FALLTROUGH
; FALLTROUGH
find_line_from_current:
// Check if line is not empty
; Check if line is not empty
jsr is_line_pointer_null
beq find_line_fail
// Fetch the high byte of line number and compare
; Fetch the high byte of line number and compare
ldy #$03
#if CONFIG_MEMORY_MODEL_60K
!ifdef CONFIG_MEMORY_MODEL_60K {
ldx #<OLDTXT+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
} else { ; CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
}
cmp LINNUM+1
beq !+
bcs find_line_fail // branch if line number too high
beq @1
bcs find_line_fail ; branch if line number too high
bne find_line_next
!:
@1:
// Fetch the low byte of line number and compare
; Fetch the low byte of line number and compare
dey
#if CONFIG_MEMORY_MODEL_60K
!ifdef CONFIG_MEMORY_MODEL_60K {
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
} else { ; CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
}
cmp LINNUM+0
beq find_line_success
bcs find_line_fail // branch if line number too high
bcs find_line_fail ; branch if line number too high
bne find_line_next
find_line_success:
@@ -59,38 +59,37 @@ find_line_success:
find_line_next:
// Advance to the next line
; Advance to the next line
jsr is_line_pointer_null
beq find_line_fail // branch in no more lines exist
beq find_line_fail ; branch in no more lines exist
ldy #$00
#if CONFIG_MEMORY_MODEL_60K
!ifdef CONFIG_MEMORY_MODEL_60K {
ldx #<OLDTXT+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
} else { ; CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
}
pha
iny
#if CONFIG_MEMORY_MODEL_60K
!ifdef CONFIG_MEMORY_MODEL_60K {
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
} else { ; CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
}
sta OLDTXT+1
pla
sta OLDTXT+0
jmp_8 find_line_from_current
+bra find_line_from_current
find_line_fail:
sec
rts
#endif
}
+29 -29
View File
@@ -1,59 +1,59 @@
// #LAYOUT# STD * #TAKE-HIGH
// #LAYOUT# * BASIC_0 #TAKE-HIGH
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE-HIGH
;; #LAYOUT# * BASIC_0 #TAKE-HIGH
;; #LAYOUT# * * #IGNORE
// This has to go $E000 or above - routine below banks out the main BASIC ROM!
; This has to go $E000 or above - routine below banks out the main BASIC ROM!
// Find the BASIC line with number in LINNUM
; Find the BASIC line with number in LINNUM
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
find_line_from_start:
// Get pointer to start of BASIC text
; Get pointer to start of BASIC text
jsr init_oldtxt
// FALLTROUGH
; FALLTROUGH
find_line_from_current:
// Unmap BASIC lower ROM
; Unmap BASIC lower ROM
lda #$26
sta CPU_R6510
// Check if line is not empty
; Check if line is not empty
jsr line_pointer_null_check // we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM
beq remap_BASIC_sec_rts // search failed if there is no program
jsr line_pointer_null_check ; we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM
beq remap_BASIC_sec_rts ; search failed if there is no program
// Fetch the high byte of line number and compare
; Fetch the high byte of line number and compare
ldy #$03
lda (OLDTXT),y
cmp LINNUM+1
beq !+
bcs remap_BASIC_sec_rts // search failed if line number too high
beq @1
bcs remap_BASIC_sec_rts ; search failed if line number too high
bne find_line_next
!:
// Fetch the low byte of line number and compare
@1:
; Fetch the low byte of line number and compare
dey
lda (OLDTXT),y
cmp LINNUM+0
beq remap_BASIC_clc_rts
bcs remap_BASIC_sec_rts // search failed if line number too high
bcs remap_BASIC_sec_rts ; search failed if line number too high
bne find_line_next
find_line_next:
// Advance to the next line
; Advance to the next line
jsr line_pointer_null_check // we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM
beq remap_BASIC_sec_rts // search failed if no more line exists
jsr line_pointer_null_check ; we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM
beq remap_BASIC_sec_rts ; search failed if no more line exists
ldy #$00
lda (OLDTXT),y
@@ -66,20 +66,20 @@ find_line_next:
pla
sta OLDTXT+0
jmp_8 find_line_from_current
+bra find_line_from_current
line_pointer_null_check: // reused by 'is_line_pointer_null'
line_pointer_null_check: ; reused by 'is_line_pointer_null'
// Check the pointer
; Check the pointer
ldy #$01 // for non-NULL pointer, high byte is almost certainly not NULL
ldy #$01 ; for non-NULL pointer, high byte is almost certainly not NULL
lda (OLDTXT),y
bne !+
bne @2
dey
lda (OLDTXT),y
bne !+
!:
bne @2
@2:
rts
remap_BASIC_clc_rts:
@@ -97,5 +97,5 @@ remap_BASIC_sec_rts:
sec
rts
}
#endif
+39 -39
View File
@@ -1,93 +1,93 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
//
// Insert the tokenised line stored at $0200.
//
// First work out where in the list to put it (find_line with the line number can be used to work
// out the insertion point, as it should abort once it finds a line number too high).
// Then all we have to do is push the rest of the BASIC text up,
// and update the pointers in all following basic lines.
//
;
; Insert the tokenised line stored at $0200.
;
; First work out where in the list to put it (find_line with the line number can be used to work
; out the insertion point, as it should abort once it finds a line number too high).
; Then all we have to do is push the rest of the BASIC text up,
; and update the pointers in all following basic lines.
;
insert_line:
// ASSUMES find_line_from_start has been called to set the insert point.
; ASSUMES find_line_from_start has been called to set the insert point.
// jsr printf
// .text "INSERTING LINE AT $"
// .byte $f1,<OLDTXT,>OLDTXT
// .byte $f0,<OLDTXT,>OLDTXT
// .byte $0d,0
; jsr printf
; .text "INSERTING LINE AT $"
; .byte $f1,<OLDTXT,>OLDTXT
; .byte $f0,<OLDTXT,>OLDTXT
; .byte $0d,0
// Get number of bytes in tokenised line after line number
; Get number of bytes in tokenised line after line number
lda __tokenise_work2
sec
sbc __tokenise_work1
// Add on the five bytes space we need (2 bytes for linkage, 2 bytes for line number, 1 byte for terminator)
; Add on the five bytes space we need (2 bytes for linkage, 2 bytes for line number, 1 byte for terminator)
clc
adc #$05
tax
// Make the space
; Make the space
jsr shift_txt_up
// Put dummy linkage, we will correct it later
; Put dummy linkage, we will correct it later
ldy #$01
tya
#if CONFIG_MEMORY_MODEL_60K
!ifdef CONFIG_MEMORY_MODEL_60K {
ldx #<OLDTXT+0
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
} else { ; CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
sta (OLDTXT),y
#endif
}
// Put the line number
; Put the line number
iny
lda LINNUM+0
#if CONFIG_MEMORY_MODEL_60K
!ifdef CONFIG_MEMORY_MODEL_60K {
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
} else { ; CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
sta (OLDTXT),y
#endif
}
iny
lda LINNUM+1
#if CONFIG_MEMORY_MODEL_60K
!ifdef CONFIG_MEMORY_MODEL_60K {
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
} else { ; CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
sta (OLDTXT),y
#endif
}
// Now store the line body itself
; Now store the line body itself
inc __tokenise_work2
!:
@1:
ldx __tokenise_work1
lda $0200,x
inc __tokenise_work1
iny
#if CONFIG_MEMORY_MODEL_60K
!ifdef CONFIG_MEMORY_MODEL_60K {
ldx #<OLDTXT+0
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
} else { ; CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
sta (OLDTXT),y
#endif
}
lda __tokenise_work1
cmp __tokenise_work2
bne !-
bne @1
// FALLTROUGH
; FALLTROUGH
update_LINKPRG_VARTAB_do_clr:
// Finish by fixing program linkage and calculating new VARTAB
; Finish by fixing program linkage and calculating new VARTAB
jsr LINKPRG
jmp update_VARTAB_do_clr
+68 -72
View File
@@ -1,142 +1,139 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
end_of_program:
// Entry point for commands not wishing to continue
; Entry point for commands not wishing to continue
pha
pha
// FALLTROUGH
; FALLTROUGH
shell_main_loop:
// Tell user we are ready
; Tell user we are ready
ldx #IDX__STR_READY
jsr print_packed_misc_str
// Mark mode as direct
; Mark mode as direct
lda #$FF
sta CURLIN+1
// Enable Kernal messages
; Enable Kernal messages
lda #$80
jsr JSETMSG
shell_read_next_line:
// Read a line of input
; Read a line of input
ldx #$00
!:
@1:
jsr JCHRIN
bcs !-
bcs @1
// Check for RETURN key
; Check for RETURN key
cmp #$0D
beq shell_got_line
// Not carriage return, so try to append to line so far
; Not carriage return, so try to append to line so far
cpx #80
bcs_16 do_STRING_TOO_LONG_error // see Computes Mapping the 64 p93
+bcs do_STRING_TOO_LONG_error ; see Computes Mapping the 64 p93
sta BUF,x
inx
jmp !-
jmp @1
shell_got_line:
// Store length of input buffer ready for tokenising
; Store length of input buffer ready for tokenising
stx __tokenise_work1
// Store 0 as the sentinel
; Store 0 as the sentinel
lda #$00
sta BUF, x
// FALLTROUGH
; FALLTROUGH
shell_strip_leading_spaces:
// Strip leading spaces from the line
; Strip leading spaces from the line
lda BUF
cmp #$20
bne shell_process_line // branch if no more leading spaces
bne shell_process_line ; branch if no more leading spaces
// We have a leading space - strip it away
; We have a leading space - strip it away
ldx #$01
!:
@2:
lda BUF,x
sta BUF-1,x
inx
cpx __tokenise_work1
bne !-
bne @2
// Reduce length of input by one
; Reduce length of input by one
dec __tokenise_work1
// Stop trying to rim if we run out of input
; Stop trying to rim if we run out of input
bne shell_strip_leading_spaces
// FALLTROUGH
; FALLTROUGH
shell_process_line:
// Print a new line
; Print a new line
jsr print_return
// Ignore empty lines
; Ignore empty lines
lda __tokenise_work1
beq shell_read_next_line
// Check if a wedge should take over
; Check if a wedge should take over
#if CONFIG_DOS_WEDGE
!ifdef CONFIG_DOS_WEDGE {
ldx __tokenise_work1 // size of the input, DOS wedges needs this XXX this should not be needed
#endif
#if CONFIG_DOS_WEDGE || CONFIG_TAPE_WEDGE
ldx __tokenise_work1 ; size of the input, DOS wedges needs this XXX this should not be needed
}
!ifdef HAS_WEDGE {
// Check if DOS wedge should take over
; Check if DOS wedge should take over
lda BUF
#if CONFIG_DOS_WEDGE
!ifdef CONFIG_DOS_WEDGE {
cmp #$40 // '@'
beq_16 wedge_dos
cmp #$40 ; '@'
+beq wedge_dos
}
!ifdef CONFIG_TAPE_WEDGE {
#endif
#if CONFIG_TAPE_WEDGE
cmp #$5F ; left arrow
+beq wedge_tape
}
cmp #$5F // left arrow
beq_16 wedge_tape
}
#endif
#endif
// Tokenise the line
; Tokenise the line
jsr tokenise_line
// Has the user entered a line of BASIC beginning with a number?
; Has the user entered a line of BASIC beginning with a number?
lda BUF
cmp #$30
bcc shell_execute_line
cmp #$39
bcs shell_execute_line
// Yes, the line begins with a number - parse it and check validity
; Yes, the line begins with a number - parse it and check validity
// The injest_number follows __tokenise_work1 as the offset into the line,
// so remember the line length somewhere else for now.
; The injest_number follows __tokenise_work1 as the offset into the line,
; so remember the line length somewhere else for now.
lda __tokenise_work1
sta __tokenise_work2
lda #$00
sta __tokenise_work1
// Try to read line number
; Try to read line number
lda #<BUF
sta TXTPTR+0
lda #>BUF
@@ -144,46 +141,46 @@ shell_process_line:
jsr fetch_line_number
// Get pointer to next char
; Get pointer to next char
lda TXTPTR+0
sta __tokenise_work1
// Got a valid line number - we will be adding/deleting a new line
; Got a valid line number - we will be adding/deleting a new line
// Skip any spaces after the line number
; Skip any spaces after the line number
ldx __tokenise_work1
!:
@3:
lda BUF,x
cmp #$20
bne !+
bne @4
inx
bne !-
!:
bne @3
@4:
stx __tokenise_work1
// FALLTROUGH
; FALLTROUGH
shell_add_delete_line:
// First make sure VARTAB is correct and clear all the variables
; First make sure VARTAB is correct and clear all the variables
jsr update_VARTAB_do_clr
// Check if line already present
; Check if line already present
jsr find_line_from_start
bcs !+
bcs @5
// Line already present - delete it
; Line already present - delete it
jsr delete_line
jsr find_line_from_start // refresh OLDTXT
!:
// Insert new line if non-zero length, i.e., that
// we are not just deleting the line.
jsr find_line_from_start ; refresh OLDTXT
@5:
; Insert new line if non-zero length, i.e., that
; we are not just deleting the line.
lda __tokenise_work1
cmp __tokenise_work2
beq !+
beq @6
jsr insert_line
!:
// No READY message after entering or deleting a line of BASIC
@6:
; No READY message after entering or deleting a line of BASIC
jmp shell_read_next_line
@@ -191,4 +188,3 @@ shell_execute_line:
jsr prepare_direct_execution
jmp execute_statements
+10 -10
View File
@@ -1,23 +1,23 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
//
// Shift the BASIC program down to cover the area of removed line
//
;
; Shift the BASIC program down to cover the area of removed line
;
shift_txt_down:
// First byte of destination is OLDTXT
; First byte of destination is OLDTXT
lda OLDTXT+0
sta memmove__dst+0
lda OLDTXT+1
sta memmove__dst+1
// First byte of source is memmove__dst + .X
; First byte of source is memmove__dst + .X
clc
txa
@@ -28,7 +28,7 @@ shift_txt_down:
adc #$00
sta memmove__src+1
// Size is distance from source to the end of BASIC text (VARTAB)
; Size is distance from source to the end of BASIC text (VARTAB)
lda VARTAB+0
sec
@@ -38,6 +38,6 @@ shift_txt_down:
sbc memmove__src+1
sta memmove__size+1
// Perform the copy
; Perform the copy
jmp shift_mem_down
+13 -14
View File
@@ -1,18 +1,18 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
//
// Shift the BASIC program up to make space for a new line
//
;
; Shift the BASIC program up to make space for a new line
;
shift_txt_up:
// Last byte of source is VARTAB-1
; Last byte of source is VARTAB-1
#if !HAS_OPCODES_65CE02
!ifndef HAS_OPCODES_65CE02 {
sec
lda VARTAB+0
@@ -22,17 +22,16 @@ shift_txt_up:
sbc #$00
sta memmove__src+1
#else // HAS_OPCODES_65CE02
} else { ; HAS_OPCODES_65CE02
lda VARTAB+0
sta memmove__src+0
lda VARTAB+1
sta memmove__src+1
dew memmove__src
}
#endif
// Last byte of destination is memmove__src + .X
; Last byte of destination is memmove__src + .X
clc
txa
@@ -43,7 +42,7 @@ shift_txt_up:
adc #$00
sta memmove__dst+1
// Size is distance from OLDTXT to the end of BASIC text (VARTAB)
; Size is distance from OLDTXT to the end of BASIC text (VARTAB)
lda VARTAB+0
sec
@@ -53,6 +52,6 @@ shift_txt_up:
sbc OLDTXT+1
sta memmove__size+1
// Perform the copy
; Perform the copy
jmp shift_mem_up
+17 -17
View File
@@ -1,31 +1,31 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 BASIC_1 #TAKE
// #LAYOUT# X16 BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# M65 BASIC_1 #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
//
// Cuts away unnecessary characters after tokenizing a keyword
//
;
; Cuts away unnecessary characters after tokenizing a keyword
;
tk_cut_away_2: // for two-bytes tokenized keywords
tk_cut_away_2: ; for two-bytes tokenized keywords
dec tk__len_unpacked
// FALLTROUGH
; FALLTROUGH
tk_cut_away_1: // for single-byte tokenized keywords
tk_cut_away_1: ; for single-byte tokenized keywords
dec tk__len_unpacked // keyword length, afterwards number of bytes to cut away
dec tk__len_unpacked ; keyword length, afterwards number of bytes to cut away
// Correct the line length
; Correct the line length
sec
lda tk__length
sbc tk__len_unpacked
sta tk__length
// Copy the remaining,. untokenized part in the proper place
; Copy the remaining,. untokenized part in the proper place
inc tk__offset
ldy tk__offset
@@ -34,13 +34,13 @@ tk_cut_away_1: // for single-byte tokenized keywords
clc
adc tk__offset
tax
!:
@1:
lda BUF, x
sta BUF, y
beq !+
beq @2
inx
iny
bne !-
!:
bne @1
@2:
rts
+76 -85
View File
@@ -1,94 +1,85 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 BASIC_1 #TAKE
// #LAYOUT# X16 BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# M65 BASIC_1 #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
//
// Packs a keyword candidate using a simple compression scheme,
// same as in 'generate_strings.cc'.
//
// This allows us to search through the compressed tokens directly
// using the compressed fragment of BASIC, and thus work out the
// token for a given piece of string.
//
// This also helps ensure that we have an implementation that is totally
// different to that of the original C64 BASIC, as well as likely
// saving a bit of space in the ROM, especially once we start implementing
// larger keyword vocabs for extended BASIC, since the compression and
// decompression machinery is of fixed size.
//
// Input:
// - .X = offset of string to pack, address is BUF ($0200) + .X
// Output:
// - see labels in 'tk_pack'
//
;
; Packs a keyword candidate using a simple compression scheme,
; same as in 'generate_strings.cc'.
;
; This allows us to search through the compressed tokens directly
; using the compressed fragment of BASIC, and thus work out the
; token for a given piece of string.
;
; This also helps ensure that we have an implementation that is totally
; different to that of the original C64 BASIC, as well as likely
; saving a bit of space in the ROM, especially once we start implementing
; larger keyword vocabs for extended BASIC, since the compression and
; decompression machinery is of fixed size.
;
; Input:
; - .X = offset of string to pack, address is BUF ($0200) + .X
; Output:
; - see labels in 'tk_pack'
;
tk_pack:
// Reuse the CPU stack - address $100 is used by 'tokenise_line.s'
.label tk__len_unpacked = $101 // length of unpacked data; it could replace 'tk__nibble_flag', but at the cost of code size/performance
.label tk__shorten_bits = $102 // 2 bytes for quick shortening of packed candidate
.label tk__nibble_flag = $104 // $00 = start from new byte, $FF = start from high nibble
.label tk__byte_offset = $105 // offset of the current byte (to place new data) in tk__packed
.label tk__packed = $106 // packed candidate, 25 bytes is enough for worst case - a 16 byte keyword
// Initialize variables
; Initialize variables
lda #$00
ldy #($04 + 25) // initialize 5 bytes of data + 25 bytes of space for packing
!:
ldy #($04 + 25) ; initialize 5 bytes of data + 25 bytes of space for packing
@1:
sta tk__len_unpacked, y
dey
bpl !-
bpl @1
// FALLTROUGH
; FALLTROUGH
tk_pack_loop:
// Get the next character
; Get the next character
lda BUF, x
// If character cannot be a part of a keyword - do not pack anything more
; If character cannot be a part of a keyword - do not pack anything more
cmp #$23 // '#' - first sane character for a keyword
bcc tk_pack_done // branch if below '#'
cmp #$7B // 'Z' + 1
bcs tk_pack_done // branch if above 'Z'
cmp #$23 ; '#' - first sane character for a keyword
bcc tk_pack_done ; branch if below '#'
cmp #$7B ; 'Z' + 1
bcs tk_pack_done ; branch if above 'Z'
// Keywords should not contain digits, colons, or semicolons
; Keywords should not contain digits, colons, or semicolons
cmp #$30
bcc !+ // branch if below '0'
bcc @2 ; branch if below '0'
cmp #$3C
bcc tk_pack_done // branch if below '<'
!:
// Try to find a nibble to encode the character
bcc tk_pack_done ; branch if below '<'
@2:
; Try to find a nibble to encode the character
ldy #$0E
!:
@3:
cmp packed_as_1n-1, y
beq tk_pack_1n
dey
bne !-
bne @3
// Try to find a 3-nibble sequence to encode the character (1st nibble is always 0xF in this case)
; Try to find a 3-nibble sequence to encode the character (1st nibble is always 0xF in this case)
ldy #TK__PACKED_AS_3N
!:
@4:
cmp packed_as_3n-1, y
beq tk_pack_3n
dey
bne !-
bne @4
// If it is not on the list, it cannot be a part of token - quit
; If it is not on the list, it cannot be a part of token - quit
// FALLTROUGH
; FALLTROUGH
tk_pack_done:
@@ -96,12 +87,12 @@ tk_pack_done:
tk_pack_1n:
// .Y contains our nibble; check whether we should start a new encoded byte
; .Y contains our nibble; check whether we should start a new encoded byte
bit tk__nibble_flag
bpl tk_pack_1n_new_byte
// Store in the high nibble of the current byte
; Store in the high nibble of the current byte
tya
@@ -114,112 +105,112 @@ tk_pack_1n:
ora tk__packed, y
sta tk__packed, y
// Adjust remaining counters / flags
; Adjust remaining counters / flags
inc tk__byte_offset
inc tk__nibble_flag // $FF -> $00
inc tk__nibble_flag ; $FF -> $00
// FALLTROUGH
; FALLTROUGH
tk_pack_1n_done:
// Put the bit mark - to indicate 1-nibble encoding
; Put the bit mark - to indicate 1-nibble encoding
clc
ror tk__shorten_bits+0
ror tk__shorten_bits+1
// FALLTROUGH
; FALLTROUGH
tk_pack_loop_next:
// Prepare for the next loop iteration - increment counters
; Prepare for the next loop iteration - increment counters
inx
inc tk__len_unpacked
// Check length, if it is OK to pack one more byte; quit if not
; Check length, if it is OK to pack one more byte; quit if not
lda tk__len_unpacked
cmp #TK__MAX_KEYWORD_LEN
beq !+ // if max length reached - quit
beq @5 ; if max length reached - quit
// Check for characters that can only end the keyword
; Check for characters that can only end the keyword
lda BUF-1, x
cmp #$41
bcs tk_pack_loop
!:
@5:
rts
tk_pack_1n_new_byte:
// Store in the low nibble of the next byte
; Store in the low nibble of the next byte
tya
ldy tk__byte_offset
sta tk__packed, y
// Adjust remaining counters / flags
; Adjust remaining counters / flags
dec tk__nibble_flag // $00 -> $FF
dec tk__nibble_flag ; $00 -> $FF
bmi tk_pack_1n_done
tk_pack_3n:
// .Y contains 2 nibbles to encode; check whether we should start a new encoded byte
; .Y contains 2 nibbles to encode; check whether we should start a new encoded byte
bit tk__nibble_flag
bpl tk_pack_3n_new_byte
// Store 1st nibble (alwys 0xF) in the high nibble of the current byte
; Store 1st nibble (alwys 0xF) in the high nibble of the current byte
phy_trash_a
+phy_trash_a
lda #$F0
ldy tk__byte_offset
ora tk__packed, y
sta tk__packed, y
// Store byte in the next byte
; Store byte in the next byte
iny
pla
sta tk__packed, y
// Adjust remaining counters / flags
; Adjust remaining counters / flags
iny
sty tk__byte_offset
inc tk__nibble_flag // $FF -> $00
inc tk__nibble_flag ; $FF -> $00
// FALLTROUGH
; FALLTROUGH
tk_pack_3n_done:
// Put the bit mark - to indicate 3-nibble encoding
; Put the bit mark - to indicate 3-nibble encoding
sec
ror tk__shorten_bits+0
ror tk__shorten_bits+1
bcc tk_pack_loop_next // branch always
bcc tk_pack_loop_next ; branch always
tk_pack_3n_new_byte:
// First store everything in the current byte, we will set '0xF' mark later
; First store everything in the current byte, we will set '0xF' mark later
tya
ldy tk__byte_offset
sta tk__packed, y
// Now store just the low nibble in the next byte
; Now store just the low nibble in the next byte
iny
and #$0F
sta tk__packed, y
// Go back for a moment and set the '0xF' mark in the low nibble
; Go back for a moment and set the '0xF' mark in the low nibble
dey
lda tk__packed, y
@@ -227,9 +218,9 @@ tk_pack_3n_new_byte:
sta tk__packed, y
iny
// Adjust remaining counters / flags
; Adjust remaining counters / flags
sty tk__byte_offset
dec tk__nibble_flag // $00 -> $FF
dec tk__nibble_flag ; $00 -> $FF
bmi tk_pack_3n_done // branch always
bmi tk_pack_3n_done ; branch always
+29 -29
View File
@@ -1,29 +1,29 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 BASIC_1 #TAKE
// #LAYOUT# X16 BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# M65 BASIC_1 #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
//
// Search for a token on the list pointed by FRESPC
//
// Input:
// - list address in FRESPC, has to be refreshed after routine call
// - uses same variables as 'tk_pack'
// Output:
// - Carry set = not found
// - .X = index of token found
//
;
; Search for a token on the list pointed by FRESPC
;
; Input:
; - list address in FRESPC, has to be refreshed after routine call
; - uses same variables as 'tk_pack'
; Output:
; - Carry set = not found
; - .X = index of token found
;
tk_search:
ldx #$00 // initial token index
ldx #$00 ; initial token index
// FALLTROUGH
; FALLTROUGH
tk_search_loop:
// Check if end of the list
; Check if end of the list
ldy #$00
lda (FRESPC), y
@@ -35,14 +35,14 @@ tk_search_loop:
cmp #$FF
bne tk_search_compare
// End of the list
; End of the list
sec
rts
tk_search_compare:
// Compare the packed candidate with the current keyword list entry
; Compare the packed candidate with the current keyword list entry
lda (FRESPC), y
cmp tk__packed, y
@@ -51,30 +51,30 @@ tk_search_compare:
cmp #$00
beq tk_search_found
// For now everything matches, try the next byte
; For now everything matches, try the next byte
iny
bne tk_search_compare // branch always
bne tk_search_compare ; branch always
tk_search_not_matching:
inx // increment token index
inx ; increment token index
// We need to find the end of the keyword on the list
// and proceed one byte further
; We need to find the end of the keyword on the list
; and proceed one byte further
cmp #$00
beq tk_search_next
!:
@1:
iny
lda (FRESPC), y
bne !-
bne @1
// FALLTROUGH
; FALLTROUGH
tk_search_next:
// Update FRESPC - advance by .Y
; Update FRESPC - advance by .Y
iny
tya
@@ -85,7 +85,7 @@ tk_search_next:
adc #$00
sta FRESPC+1
bcc tk_search_loop // branch always
bcc tk_search_loop ; branch always
tk_search_found:
+36 -36
View File
@@ -1,44 +1,44 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 BASIC_1 #TAKE
// #LAYOUT# X16 BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# M65 BASIC_1 #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
//
// Shortens a keyword candidate previously packed by tk_pack by 1 character
//
// Input:
// - uses same variables as 'tk_pack'
//
;
; Shortens a keyword candidate previously packed by tk_pack by 1 character
;
; Input:
; - uses same variables as 'tk_pack'
;
tk_shorten:
// First make sure we actually can shorten anything
; First make sure we actually can shorten anything
dec tk__len_unpacked
beq tk_shorten_end
// Now check if the last character was encoded as 1 nibble or 3 nibbles
; Now check if the last character was encoded as 1 nibble or 3 nibbles
asl tk__shorten_bits+1
rol tk__shorten_bits+0
bcs tk_shorten_3n
// FALLTROUGH
; FALLTROUGH
tk_shorten_1n:
ldy tk__byte_offset // will be needed in both cases
ldy tk__byte_offset ; will be needed in both cases
// Now we need to check which nibble to cut away
; Now we need to check which nibble to cut away
bit tk__nibble_flag
bmi tk_shorten_1n_lo
// FALLTROUGH
; FALLTROUGH
tk_shorten_1n_hi: // tk__nibble_flag = $00, both nibbles free
tk_shorten_1n_hi: ; tk__nibble_flag = $00, both nibbles free
// Go back one byte and clear the high nibble only
; Go back one byte and clear the high nibble only
dey
sty tk__byte_offset
@@ -47,62 +47,62 @@ tk_shorten_1n_hi: // tk__nibble_flag = $00, both nibbles fr
and #$0F
sta tk__packed, y
// Adjust remaining counters / flags, and quit
; Adjust remaining counters / flags, and quit
dec tk__nibble_flag // $00 -> $FF
dec tk__nibble_flag ; $00 -> $FF
// FALLTROUGH
; FALLTROUGH
tk_shorten_end:
rts
tk_shorten_1n_lo: // tk__nibble_flag = $FF, only the high nibble is free
tk_shorten_1n_lo: ; tk__nibble_flag = $FF, only the high nibble is free
// Clear the whole byte, it will be faster
; Clear the whole byte, it will be faster
lda #$00
sta tk__packed, y
// Adjust remaining counters / flags, and quit
; Adjust remaining counters / flags, and quit
inc tk__nibble_flag // $FF -> $00
inc tk__nibble_flag ; $FF -> $00
rts
tk_shorten_3n:
ldy tk__byte_offset // will be needed in both cases
ldy tk__byte_offset ; will be needed in both cases
lda #$00
// Now we need to check which nibble to cut away
; Now we need to check which nibble to cut away
bit tk__nibble_flag
bmi tk_shorten_3n_2bytes
// FALLTROUGH
; FALLTROUGH
tk_shorten_3n_byte_nibble: // tk__nibble_flag = $00, both nibbles free
tk_shorten_3n_byte_nibble: ; tk__nibble_flag = $00, both nibbles free
// Go back one byte, clear it, go back and clear the high nibble only
; Go back one byte, clear it, go back and clear the high nibble only
dey
sta tk__packed, y
// Reuse 'tk_shorten_1n_hi'
; Reuse 'tk_shorten_1n_hi'
sty tk__byte_offset
jmp_8 tk_shorten_1n_hi
+bra tk_shorten_1n_hi
tk_shorten_3n_2bytes: // tk__nibble_flag = $FF, only the high nibble is free
tk_shorten_3n_2bytes: ; tk__nibble_flag = $FF, only the high nibble is free
// Clear the byte, go back, clear one more byte
; Clear the byte, go back, clear one more byte
sta tk__packed, y
dey
sta tk__packed, y
// Adjust remaining counters / flags, and quit
; Adjust remaining counters / flags, and quit
sty tk__byte_offset
inc tk__nibble_flag // $FF -> $00
inc tk__nibble_flag ; $FF -> $00
rts
+67 -76
View File
@@ -1,53 +1,48 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 * #TAKE
// #LAYOUT# X16 BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# M65 * #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
//
// Tokenise a line of BASIC stored at $0200
//
// Input:
// - length in __tokenise_work1
//
;
; Tokenise a line of BASIC stored at $0200
;
; Input:
; - length in __tokenise_work1
;
tokenise_line:
#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0)
!ifdef SEGMENT_M65_BASIC_0 {
jsr map_BASIC_1
jsr_ind VB1__tokenise_line
jmp map_NORMAL
jsr map_BASIC_1
jsr (VB1__tokenise_line)
jmp map_NORMAL
#else
} else {
// Reuse the CPU stack - addresses above $100 are used by 'tk_pack.s'
.label tk__offset = $100 // offset into string
.label tk__length = __tokenise_work1 // length of the raw string
// Initialize variables
; Initialize variables
lda #$00
sta tk__offset
// Terminate input string with $00
; Terminate input string with $00
// XXX do we need this?
; XXX do we need this?
ldx tk__length
sta BUF, x
// FALLTROUGH
; FALLTROUGH
tokenise_line_loop:
// Check if we have reached end of the line
; Check if we have reached end of the line
lda tk__offset
cmp tk__length
beq tokenise_line_done
// Check for some special characters
; Check for some special characters
ldx tk__offset
lda BUF, x
@@ -59,16 +54,16 @@ tokenise_line_loop:
beq tokenise_line_pi
cmp #$3F
beq tokenise_line_question_mark // shortcut for PRINT command
beq tokenise_line_question_mark ; shortcut for PRINT command
// Try to tokenise
; Try to tokenise
jsr tk_pack
!:
@1:
lda tk__len_unpacked
beq tokenise_line_char // branch if attempt to tokenise failed
beq tokenise_line_char ; branch if attempt to tokenise failed
// Check for BASIC V2 tokens
; Check for BASIC V2 tokens
lda #<packed_freq_keywords_V2
sta FRESPC+0
@@ -76,9 +71,9 @@ tokenise_line_loop:
sta FRESPC+1
jsr tk_search
bcc tokenise_line_keyword_V2 // branch if keyword identified
bcc tokenise_line_keyword_V2 ; branch if keyword identified
// Check for extended tokens
; Check for extended tokens
lda #<packed_freq_keywords_01
sta FRESPC+0
@@ -86,9 +81,9 @@ tokenise_line_loop:
sta FRESPC+1
jsr tk_search
bcc tokenise_line_keyword_01 // branch if keyword identified
bcc tokenise_line_keyword_01 ; branch if keyword identified
#if !HAS_SMALL_BASIC
!ifndef HAS_SMALL_BASIC {
lda #<packed_freq_keywords_02
sta FRESPC+0
@@ -96,11 +91,10 @@ tokenise_line_loop:
sta FRESPC+1
jsr tk_search
bcc tokenise_line_keyword_02 // branch if keyword identified
bcc tokenise_line_keyword_02 ; branch if keyword identified
}
#endif
#if ROM_LAYOUT_M65
!ifdef CONFIG_MB_M65 {
lda #<packed_freq_keywords_03
sta FRESPC+0
@@ -108,50 +102,49 @@ tokenise_line_loop:
sta FRESPC+1
jsr tk_search
bcc tokenise_line_keyword_03 // branch if keyword identified
bcc tokenise_line_keyword_03 ; branch if keyword identified
}
#endif
// Shorten packed keyword candidate and try again
; Shorten packed keyword candidate and try again
jsr tk_shorten
jmp_8 !-
+bra @1
tokenise_line_keyword_V2:
// .X contains a token ID, starting from 0
; .X contains a token ID, starting from 0
txa
pha // store the token on the stack, we will need it for REM support
pha ; store the token on the stack, we will need it for REM support
// Store the token
; Store the token
ldx tk__offset
clc
adc #$80
sta BUF, x
// Cut away unnecessary bytes
; Cut away unnecessary bytes
jsr tk_cut_away_1
// Special handling for REM command - after this one nothing more should be tokenised
; Special handling for REM command - after this one nothing more should be tokenised
pla
cmp #$0F // REM token index
cmp #$0F ; REM token index
bne tokenise_line_loop
// FALLTROUGH
; FALLTROUGH
tokenise_line_done:
// Quit
; Quit
rts
tokenise_line_quote:
// For the quote, we advance without tokenizing, until the next quote is found
; For the quote, we advance without tokenizing, until the next quote is found
inc tk__offset
ldx tk__offset
@@ -161,21 +154,21 @@ tokenise_line_quote:
cmp #$22
beq tokenise_line_char
bne tokenise_line_quote // branch always
bne tokenise_line_quote ; branch always
tokenise_line_pi:
lda #$FF // token for PI
skip_2_bytes_trash_nvz
lda #$FF ; token for PI
+skip_2_bytes_trash_nvz
// FALLTROUGH
; FALLTROUGH
tokenise_line_question_mark:
lda #$99 // token for PRINT
lda #$99 ; token for PRINT
sta BUF, x
// FALLTROUGH
; FALLTROUGH
tokenise_line_char:
@@ -183,44 +176,42 @@ tokenise_line_char:
jmp tokenise_line_loop
// Support for extended keyword lists
; Support for extended keyword lists
#if ROM_LAYOUT_M65
!ifdef CONFIG_MB_M65 {
tokenise_line_keyword_03:
// Store the token list index
; Store the token list index
lda #$03
skip_2_bytes_trash_nvz
+skip_2_bytes_trash_nvz
// FALLTROUGH
; FALLTROUGH
}
#endif
#if !HAS_SMALL_BASIC
!ifndef HAS_SMALL_BASIC {
tokenise_line_keyword_02:
// Store the token list index
; Store the token list index
lda #$02
skip_2_bytes_trash_nvz
+skip_2_bytes_trash_nvz
// FALLTROUGH
#endif
; FALLTROUGH
}
tokenise_line_keyword_01:
// Store the token list index
; Store the token list index
lda #$01
ldy tk__offset
sta BUF, y
// Store the sub-token itself
; Store the sub-token itself
inx
txa
@@ -228,9 +219,9 @@ tokenise_line_keyword_01:
sty tk__offset
sta BUF, y
// Cut away unnecessary bytes
; Cut away unnecessary bytes
jsr tk_cut_away_2
jmp tokenise_line_loop
#endif // ROM layout
} ; ROM layout
+15 -15
View File
@@ -1,10 +1,10 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
//
// Calculate the VARTAB value - to mark the end of BASIC program code. Also clears all variables.
//
;
; Calculate the VARTAB value - to mark the end of BASIC program code. Also clears all variables.
;
update_VARTAB_do_clr:
@@ -12,7 +12,7 @@ update_VARTAB_do_clr:
sta OLDTXT+0
lda TXTTAB+1
sta OLDTXT+1
!:
@1:
lda OLDTXT+0
sta VARTAB+0
lda OLDTXT+1
@@ -22,26 +22,26 @@ update_VARTAB_do_clr:
lda OLDTXT+0
ora OLDTXT+1
bne !- // branch if pointer not NULL
bne @1 ; branch if pointer not NULL
// Correct VARTAB by 2 bytes NULL pointer
; Correct VARTAB by 2 bytes NULL pointer
#if HAS_OPCODES_65CE02
!ifdef HAS_OPCODES_65CE02 {
inw VARTAB
inw VARTAB
#else
} else {
clc
lda VARTAB+0
adc #$02
sta VARTAB+0
bcc !+
bcc @2
inc VARTAB+1
!:
#endif
@2:
}
// Call CLR to set-up remaining variables
; Call CLR to set-up remaining variables
jmp do_clr