|
| 1 | +;---------------------------------------------------------------------- |
| 2 | +; Number of commands |
| 3 | +;---------------------------------------------------------------------- |
| 4 | +.scope SDK_ROM |
| 5 | + command_nb .set 0 |
| 6 | + vectors_set .set 0 |
| 7 | +.endscope |
| 8 | + |
| 9 | +;---------------------------------------------------------------------- |
| 10 | +; |
| 11 | +; usage: |
| 12 | +; add_command "command_name"[, command_address] |
| 13 | +; |
| 14 | +; note: |
| 15 | +; command_address defaults to command_name |
| 16 | +; Ex: add_command "test" will use label test for command_address |
| 17 | +; |
| 18 | +; Add command_name to the rom |
| 19 | +;---------------------------------------------------------------------- |
| 20 | +.macro add_command command_name, address |
| 21 | + |
| 22 | + verbose 2, .sprintf("*** Add command: %s", command_name) |
| 23 | + |
| 24 | + .assert SDK_ROM::vectors_set = 0, ldwarning, .sprintf("Command '%s' defined after set_orix_vectors", command_name) |
| 25 | + |
| 26 | + .pushseg |
| 27 | + |
| 28 | + .segment "INSTRTBL" |
| 29 | + .ident(.sprintf("%s_name",command_name)) := * |
| 30 | + .asciiz command_name |
| 31 | + |
| 32 | + .segment "INSTRTBL2" |
| 33 | + .word .ident(.sprintf("%s_name",command_name)) |
| 34 | + |
| 35 | + .if .not .xmatch({address}, NOOP) |
| 36 | + .segment "INSTRJMP" |
| 37 | + |
| 38 | + .if .not .blank({address}) |
| 39 | + .addr address |
| 40 | + .else |
| 41 | + .word .ident(command_name) |
| 42 | + .endif |
| 43 | + .endif |
| 44 | + |
| 45 | + SDK_ROM::command_nb .set SDK_ROM::command_nb+1 |
| 46 | + |
| 47 | + .popseg |
| 48 | +.endmacro |
| 49 | + |
| 50 | + |
| 51 | +;---------------------------------------------------------------------- |
| 52 | +; |
| 53 | +; usage: |
| 54 | +; command "command_name" |
| 55 | +; |
| 56 | +; note: |
| 57 | +; Open command scope, don't forget to use endcommand to close |
| 58 | +; the scope |
| 59 | +; |
| 60 | +; Add command_name to the rom |
| 61 | +;---------------------------------------------------------------------- |
| 62 | +.macro command command_name |
| 63 | + |
| 64 | + verbose 2, .sprintf("*** Add command: %s", command_name) |
| 65 | + |
| 66 | + .assert SDK_ROM::vectors_set = 0, ldwarning, .sprintf("Command '%s' defined after set_orix_vectors", command_name) |
| 67 | + |
| 68 | + .pushseg |
| 69 | + |
| 70 | + .segment "INSTRTBL" |
| 71 | + .ident(.sprintf("%s_name",command_name)) := * |
| 72 | + .asciiz command_name |
| 73 | + |
| 74 | + .segment "INSTRTBL2" |
| 75 | + .word .ident(.sprintf("%s_name",command_name)) |
| 76 | + |
| 77 | + .segment "INSTRJMP" |
| 78 | + .word .ident(command_name) |
| 79 | + |
| 80 | + |
| 81 | + SDK_ROM::command_nb .set SDK_ROM::command_nb+1 |
| 82 | + |
| 83 | + .popseg |
| 84 | + |
| 85 | + .proc .ident(command_name) |
| 86 | +.endmacro |
| 87 | + |
| 88 | + |
| 89 | +;---------------------------------------------------------------------- |
| 90 | +; |
| 91 | +; usage: |
| 92 | +; endcommand |
| 93 | +; |
| 94 | +; Close command scope |
| 95 | +;---------------------------------------------------------------------- |
| 96 | +.macro endcommand |
| 97 | + .endproc |
| 98 | +.endmacro |
| 99 | + |
| 100 | + |
| 101 | +;---------------------------------------------------------------------- |
| 102 | +; |
| 103 | +; usage: |
| 104 | +; set_orix_vectors rom_type, parse_vector, signature |
| 105 | +; |
| 106 | +; note: |
| 107 | +; signature: may be "string" or label |
| 108 | +; if signature is a "string", this macro create new label rom_signaure |
| 109 | +; |
| 110 | +; Set orix rom vectors |
| 111 | +;---------------------------------------------------------------------- |
| 112 | +.macro set_orix_vectors rom_type, parse_vector, signature |
| 113 | + .local _signature |
| 114 | + |
| 115 | + .pushseg |
| 116 | + |
| 117 | + ;.import __INSTRJMP_LOAD__ |
| 118 | + ;.import __INSTRTBL_LOAD__ |
| 119 | + |
| 120 | + .if .match(signature,"") |
| 121 | + .segment "SIGNATURE" |
| 122 | + .import __SIGNATURE_LOAD__ |
| 123 | + |
| 124 | + ; A voir si dans ce cas on doit définir le label "rom_signature" ou non |
| 125 | + ; .ident(.sprintf("rom_signature")) := * |
| 126 | + |
| 127 | + _signature := __SIGNATURE_LOAD__ |
| 128 | + .asciiz signature |
| 129 | + .else |
| 130 | + _signature := signature |
| 131 | + .endif |
| 132 | + |
| 133 | + .segment "ORIXVECT" |
| 134 | + .byte rom_type |
| 135 | + .addr parse_vector |
| 136 | + .addr parse_vector |
| 137 | + .addr parse_vector |
| 138 | + .byte SDK_ROM::command_nb |
| 139 | + .word _signature |
| 140 | + |
| 141 | + .popseg |
| 142 | + |
| 143 | + SDK_ROM::vectors_set .set 1 |
| 144 | + |
| 145 | + verbose 1, .sprintf("*** Bank name: %s", signature) |
| 146 | + verbose 1, .sprintf("*** Commands : %d", SDK_ROM::command_nb) |
| 147 | + |
| 148 | + ;.assert SDK_ROM::command_nb > 0, warning, "No command defined" |
| 149 | + |
| 150 | +.endmacro |
| 151 | + |
| 152 | + |
| 153 | +;---------------------------------------------------------------------- |
| 154 | +; |
| 155 | +; usage: |
| 156 | +; set_cpu_vectors nmi, reset, irq |
| 157 | +; |
| 158 | +; Set 6502 vectors |
| 159 | +;---------------------------------------------------------------------- |
| 160 | +.macro set_cpu_vectors nmi, reset, irq |
| 161 | + .pushseg |
| 162 | + |
| 163 | + .segment "CPUVECT" |
| 164 | + .addr nmi |
| 165 | + .addr reset |
| 166 | + .addr irq |
| 167 | + |
| 168 | + .popseg |
| 169 | +.endmacro |
| 170 | + |
| 171 | +; ---------------------------------------------------------------------------- |
| 172 | +; verbose level, string |
| 173 | +; ---------------------------------------------------------------------------- |
| 174 | +; Affiche un message si level <= VERBOSE_LEVEL |
| 175 | +; ---------------------------------------------------------------------------- |
| 176 | +.macro verbose level, string |
| 177 | + .ifdef VERBOSE_LEVEL |
| 178 | + .if level <= ::VERBOSE_LEVEL |
| 179 | + .out string |
| 180 | + .endif |
| 181 | + .endif |
| 182 | +.endmacro |
0 commit comments