11; This routine check if IRQ vector is set to $fffe, if yes we continue or else, we proceed to next bank
22; Also if $FFF7 contains 0, it means that there is no command, then we skip
33
4-
4+ ; At the beginning of this routine, we already swapped into the a bank to check
5+ ; Bank and twilighte_banking_register are managed in the kernel and call this routines located in the main ram
56kernel_memory_driver_to_copy:
67 lda VIA2::PRA
78 and KERNEL_TMP_XEXEC ; But select a bank in BNK_TO_SWITCH
@@ -23,17 +24,17 @@ test_debug:
2324 sta RESB+1
2425; d15E
2526 ldx #$00
26-
2727read_command_from_bank_driver_mloop:
2828 ldy #$00
2929read_command_from_bank_driver_next_char:
30- lda (RES),y
31- cmp (RESB),y ; Same character?
30+ lda (RES),y ; RES contains the ptr of the string typed by the user when XEXEC is launched
31+ cmp (RESB),y ; Same character? RESB contains the ptr of the command in the rom
3232 beq read_command_from_bank_driver_no_space
33- cmp #' ' ; space ?
33+ cmp #' ' ; Space ?
3434 bne command_not_found_no_inc
35- lda (RESB),y ; Last character of the command name?
36- read_command_from_bank_driver_no_space: ; FIXME
35+ lda (RESB),y ; Last character of the command name?
36+
37+ read_command_from_bank_driver_no_space:
3738 cmp #$00 ; Test end of command name or EOL
3839 beq read_command_from_bank_driver_command_found
3940 iny
@@ -42,13 +43,20 @@ read_command_from_bank_driver_no_space: ; FIXME
4243
4344command_not_found:
4445 ; read_until_we_reached $00
46+ ; this code is to detect the end of the string of the command tested
47+ ; For example, if the command launch in RES is "bank" and RESB a ptr to is "ls" string in the current bank, we "iny"
48+ ; the value in order to reach EOL of "ls". in that case, we add the length of "ls"+0 to the RESB ptr in order to read the next command
4549 iny
46- command_not_found_no_inc:
4750
51+ ; Theses following lines are here to exit this routine, if we reach y=12, because it's impossible to have a command longer than 12 bytes.
52+ cpy #12
53+ beq exit_to_kernel
4854
55+ command_not_found_no_inc:
4956 lda (RESB),y
5057 beq @add
5158 bne command_not_found
59+
5260@add :
5361 iny
5462 tya
@@ -59,7 +67,7 @@ command_not_found_no_inc:
5967read_command_from_bank_driver_do_not_inc:
6068 sta RESB
6169 inx
62- cpx $FFF7 ; Number of command
70+ cpx $FFF7 ; loop until we reach number of command of the rom
6371 bne read_command_from_bank_driver_mloop
6472 ; at this step we did not found the command in the rom
6573exit_to_kernel:
@@ -70,9 +78,8 @@ exit_to_kernel:
7078 ldy #ENOENT ; error
7179
7280 rts
73- read_command_from_bank_driver_command_found:
74-
7581
82+ read_command_from_bank_driver_command_found:
7683 ; X contains the id of the command to start
7784 lda $FFF3
7885 sta RES
@@ -90,28 +97,33 @@ read_command_from_bank_driver_patch1:
9097read_command_from_bank_driver_patch2:
9198 sta VEXBNK+2 ; Will store in read_command_from_bank_driver_to_patch
9299
93- lda VIA2::PRA
94- ora #%00000111 ; Return to telemon
95- sta VIA2::PRA
100+ lda #$07 ; Return to telemon
101+ jsr $46a
102+
103+
96104 jsr _XFORK
97105
98106 ; we reached max process to launch ?
99107 lda KERNEL_ERRNO
100108 cmp #KERNEL_ERRNO_MAX_PROCESS_REACHED
101109 beq exit_to_kernel ; Yes we reached max process we exit
102110
103- lda VIA2::PRA
104- and KERNEL_TMP_XEXEC ; But select a bank in BNK_TO_SWITCH
105- sta VIA2::PRA
111+ lda KERNEL_TMP_XEXEC
112+ jsr $46A
113+
114+
115+
116+ lda TR0
117+ ldy TR1 ; Send command line in A & Y
106118
107- lda TR0
108- ldy TR1 ; Send command line in A & Y
109119read_command_from_bank_driver_to_patch:
110120 jsr VEXBNK
111121 pha
112- lda VIA2::PRA
113- ora #%00000111 ; Return to kernel
114- sta VIA2::PRA
122+
123+ lda #$07 ; Return to telemon
124+ jsr $46A
125+
126+
115127 pla
116128 ldy #EOK
117129
0 commit comments