Terminal program for MailStation devices
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

crt0: support running from dataflash

When running from loader.asm, we're loaded into RAM so everything in
our address space is writable. When running from dataflash, we're
read-only.

On start, load in a RAM page in the other slot, copy our 16kb of
dataflash to RAM, jump there, swap the RAM page into the slot where
we started, then jump back. This makes our 16kb of address space
read/write on the fly.

+243 -199
+5 -2
Makefile
··· 16 16 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 17 # 18 18 19 - ASZ80 ?= sdasz80 -l 19 + ASZ80 ?= sdasz80 -l -ff 20 20 SDCC ?= sdcc -mz80 21 21 22 22 SRCDIR ?= ${.CURDIR} ··· 73 73 # code-loc must be far enough to hold _HEADER code in crt0 74 74 msterm.ihx: crt0.rel isr.rel putchar.rel getchar.rel lpt.rel mailstation.rel \ 75 75 modem.rel msterm.rel mslib.rel csi.rel settings.rel 76 - $(SDCC) --no-std-crt0 --code-loc 0x8100 --data-loc 0x0000 -o ${.TARGET} $> 76 + $(SDCC) --no-std-crt0 --code-loc 0x4100 --data-loc 0x0000 -o ${.TARGET} $> 77 77 78 78 msterm.bin: msterm.ihx 79 79 objcopy -Iihex -Obinary $> $@ ··· 81 81 echo "${.TARGET} overflows a dataflash page, must be <= 16384"; \ 82 82 exit 1; \ 83 83 fi 84 + 85 + disasm: msterm.bin 86 + z80dasm -al -g 0x4000 $> > msterm.dasm 84 87 85 88 upload: all 86 89 sudo ../../mailstation-tools/obj/sendload -p 0x4000 msterm.bin
+61 -53
crt0.s
··· 26 26 27 27 .area _HEADER (ABS) 28 28 29 - ; when running as a program from dataflash 30 - ; be sure to change --code-loc parameter in Makefile to 0x4100 31 - ;.org 0x4000 32 - 33 - ; when running from loader 34 - .org 0x8000 35 - 29 + .org RUN_ADDR 30 + start: 36 31 jp boot 37 32 38 33 .dw (icons) ··· 62 57 .dw #0x0022 ; icon width (34, 5 bytes per row) 63 58 .db #0x22 ; icon height (34) 64 59 65 - ; icon bitmap, low-order bit displays on the LEFT of each byte!) 66 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 67 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 68 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 69 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 70 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0x00,#0xaa,#0xaa 71 - .db #0x55,#0x55,#0x00,#0x55,#0x55, #0xaa,#0xaa,#0x00,#0xaa,#0xaa 72 - .db #0x55,#0x55,#0x00,#0x55,#0x55, #0xaa,#0xaa,#0x00,#0xaa,#0xaa 73 - .db #0x55,#0x55,#0x00,#0x55,#0x55, #0xaa,#0xaa,#0x00,#0xaa,#0xaa 74 - .db #0x55,#0x55,#0x00,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 75 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 76 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 77 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 78 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 79 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 80 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 81 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 82 - .db #0x55,#0x55,#0x55,#0x55,#0x55, #0xaa,#0xaa,#0xaa,#0xaa,#0xaa 60 + .db #0x00, #0x00, #0x00, #0x00, #0x00 ; .................................. 61 + .db #0x00, #0x00, #0x00, #0xe0, #0x03 ; .............................##### 62 + .db #0x00, #0x00, #0x00, #0x20, #0x02 ; .............................#...# 63 + .db #0x00, #0x00, #0x00, #0xa0, #0x02 ; .............................#.#.# 64 + .db #0x00, #0x00, #0x00, #0xa0, #0x02 ; .............................#.#.# 65 + .db #0x00, #0x00, #0x00, #0xa0, #0x02 ; .............................#.#.# 66 + .db #0x00, #0x00, #0x00, #0xe0, #0x03 ; .............................##### 67 + .db #0x00, #0x00, #0x00, #0x80, #0x00 ; ...............................#.. 68 + .db #0x00, #0xff, #0xff, #0x63, #0x00 ; ........##################...##... 69 + .db #0x00, #0x01, #0x00, #0x12, #0x00 ; ........#................#..#..... 70 + .db #0x00, #0x01, #0x00, #0x12, #0x00 ; ........#................#..#..... 71 + .db #0x00, #0x01, #0x00, #0x0a, #0x00 ; ........#................#.#...... 72 + .db #0xe0, #0x01, #0x00, #0x1e, #0x00 ; .....####................####..... 73 + .db #0xf0, #0x01, #0x00, #0x3e, #0x00 ; ....#####................#####.... 74 + .db #0xf0, #0x01, #0x00, #0x36, #0x00 ; ....#####................##.##.... 75 + .db #0xf8, #0xff, #0xff, #0x7f, #0x00 ; ...############################... 76 + .db #0xa8, #0x92, #0x24, #0x55, #0x00 ; ...#.#.#.#..#..#..#..#..#.#.#.#... 77 + .db #0xfc, #0xff, #0xff, #0xff, #0x00 ; ..##############################.. 78 + .db #0x54, #0x55, #0x55, #0x95, #0x00 ; ..#.#.#.#.#.#.#.#.#.#.#.#.#.#..#.. 79 + .db #0xfe, #0xff, #0xff, #0xff, #0x01 ; .################################. 80 + .db #0xaa, #0xaa, #0xaa, #0x2a, #0x01 ; .#.#.#.#.#.#.#.#.#.#.#.#.#.#.#..#. 81 + .db #0xfe, #0xff, #0xff, #0xff, #0x01 ; .################################. 82 + .db #0x53, #0x55, #0x55, #0x15, #0x03 ; ##..#.#.#.#.#.#.#.#.#.#.#.#.#...## 83 + .db #0xff, #0xff, #0xff, #0xff, #0x03 ; ################################## 84 + .db #0x26, #0x00, #0x00, #0xa8, #0x01 ; .##..#.....................#.#.##. 85 + .db #0xfc, #0xff, #0xff, #0xff, #0x00 ; ..##############################.. 86 + .db #0x00, #0x00, #0x00, #0x00, #0x00 ; .................................. 87 + .db #0x00, #0x00, #0x00, #0x00, #0x00 ; .................................. 88 + .db #0x00, #0x00, #0x00, #0x00, #0x00 ; .................................. 89 + .db #0x00, #0x00, #0x00, #0x00, #0x00 ; .................................. 90 + .db #0x00, #0x00, #0x00, #0x00, #0x00 ; .................................. 91 + .db #0x00, #0x00, #0x00, #0x00, #0x00 ; .................................. 92 + .db #0x00, #0x00, #0x00, #0x00, #0x00 ; .................................. 93 + .db #0x00, #0x00, #0x00, #0x00, #0x00 ; .................................. 83 94 84 95 icon2: 85 96 ; not used ··· 88 99 iconend: 89 100 90 101 boot: 91 - ; preserve old slot4000 for later 92 - ld a, (#06) 93 - ld (startup_slot4000device), a 94 - ld a, (#05) 95 - ld (startup_slot4000page), a 96 - 97 102 xor a 98 103 out (#0x0d), a ; put the cpu in its highest speed 99 104 100 - call gsinit ; initialize global variables 105 + ; swap in a page of ram 106 + ld a, #DEVICE_RAM 107 + out (#SLOT_DEVICE), a 108 + out (#SLOT_PAGE), a 109 + 110 + ; copy ourselves into ram 111 + ld de, #SLOT_ADDR 112 + ld hl, #RUN_ADDR 113 + ld bc, #0x4000 114 + ldir ; ld (de), (hl), de++, hl++, bc-- 115 + 116 + jp SLOT_ADDR + (hijump - start) 117 + 118 + hijump: 119 + ; SP is now in SLOT_ADDR, put our new RAM page into RUN_DEVICE/PAGE 120 + out (#RUN_DEVICE), a 121 + out (#RUN_PAGE), a 122 + 123 + ; then jump back there 124 + jp RUN_ADDR + (lojump - start) 125 + 126 + lojump: 101 127 call patch_isr ; install new ISR 102 128 call _main ; main c code 103 129 jp _exit ··· 107 133 108 134 .area _CODE 109 135 110 - .area _GSINIT 111 - 112 - gsinit:: 113 - 114 - .area _GSFINAL 115 - 116 - gsfinal:: 117 - ret 118 - 119 136 ; variables 120 137 .area _BSS 121 138 122 - startup_slot4000device: 123 - .ds 1 124 - startup_slot4000page: 125 - .ds 1 126 - 127 139 _debug0:: 128 140 .db #0 129 141 _debug1:: ··· 141 153 142 154 .area _CODE 143 155 144 - ; exit handler, jump back to loader 156 + ; exit handler, restart 145 157 _exit:: 146 - ld a, (startup_slot4000device) 147 - ld (#06), a 148 - ld a, (startup_slot4000page) 149 - ld (#05), a 150 - jp 0x4000 158 + call _reboot 151 159 152 160 _powerdown_mode:: 153 161 call #0x0a6b ; firmware powerdownmode function ··· 175 183 ld a, (p2shadow) 176 184 res 4, a 177 185 write_p2: 178 - ld (hl), a 186 + ld (p2shadow), a 179 187 out (#0x02), a ; write p2shadow to port2 180 188 pop af 181 189 pop hl
-16
mailstation.h
··· 45 45 __sfr __at(0x1c) rtc10years; 46 46 __sfr __at(0x28) port28; 47 47 48 - /* v2.54 firmware */ 49 - extern volatile unsigned char __at(0xdba2) p2shadow; 50 - extern volatile unsigned char __at(0xdba3) p3shadow; 51 - extern volatile unsigned char __at(0xdba0) p28shadow; 52 - 53 - /* device IDs that can be swapped into page4000 */ 54 - #define DEVICE_CODEFLASH 0x00 // 64 pages 55 - #define DEVICE_RAM 0x01 // 08 pages 56 - #define DEVICE_LCD_LEFT 0x02 // 01 pages 57 - #define DEVICE_DATAFLASH 0x03 // 32 pages 58 - #define DEVICE_LCD_RIGHT 0x04 // 01 pages 59 - #define DEVICE_MODEM 0x05 // 01 pages 60 - 61 - /* once DEVICE_LCD_{LEFT,RIGHT} is swapped into page4000, LCD starts here */ 62 - #define LCD_START 0x4038 63 - 64 48 /* LCD parameters (2 screens) */ 65 49 #define LCD_WIDTH (160 * 2) // 320 66 50 #define LCD_HEIGHT 128
+28 -2
mailstation.inc
··· 1 1 ; vim:syntax=z8a:ts=8:sw=8 2 2 3 + ; ; when running from Loader, we are loaded at 0x8000 and use slot 4 4 + ; ; for swapping devices 5 + ; ; 6 + ; ; the --code-loc parameter in Makefile should be 0x8100 7 + ; .equ RUN_ADDR, #0x8000 8 + ; .equ RUN_DEVICE, #0x8 9 + ; .equ RUN_PAGE, #0x7 10 + ; .equ SLOT_ADDR, #0x4000 11 + ; .equ SLOT_DEVICE, #0x6 12 + ; .equ SLOT_PAGE, #0x5 13 + 14 + ; when running from dataflash, we are loaded at 0x4000 and use slot 8 15 + ; for swapping devices 16 + ; 17 + ; the --code-loc parameter in Makefile should be 0x4100 18 + .equ RUN_ADDR, #0x4000 19 + .equ RUN_DEVICE, #0x6 20 + .equ RUN_PAGE, #0x5 21 + .equ SLOT_ADDR, #0x8000 22 + .equ SLOT_DEVICE, #0x8 23 + .equ SLOT_PAGE, #0x7 24 + 25 + 3 26 ; for firmware v2.54 4 27 ; variables 5 28 .equ p2shadow, #0xdba2 ··· 34 57 .equ LCD_ROWS, #LCD_HEIGHT / FONT_HEIGHT ; 16 35 58 .equ TEXT_ROWS, #LCD_ROWS - 1 ; 15 36 59 60 + .equ DEVICE_RAM, #0x01 37 61 .equ DEVICE_LCD_LEFT, #0x02 38 62 .equ DEVICE_DATAFLASH, #0x03 39 63 .equ DEVICE_LCD_RIGHT, #0x04 64 + .equ DEVICE_MODEM, #0x05 40 65 41 - ; addressing the LCD once it's in slot4000_device 42 - .equ LCD_START, #0x4038 66 + ; addressing the LCD once it's loaded in SLOT_ADDR 67 + .equ LCD_START, #SLOT_ADDR + 0x0038 43 68 44 69 .equ ATTR_BIT_CURSOR, #0 45 70 .equ ATTR_BIT_REVERSE, #1 ··· 68 93 .globl _delay 69 94 .globl _lptsend 70 95 .globl _lptsend16 96 + .globl _lptrecv 71 97 .globl div16 72 98 .globl mult8 73 99 .globl mult16
+83 -59
modem.s
··· 113 113 ; l33f8 114 114 ld a, #0x01 115 115 ld (#0xe638), a 116 - in a, (#0x06) ; store old slot4000device 116 + in a, (#SLOT_DEVICE) ; store old slot device 117 117 push af 118 118 ld a, (p2shadow) ; read p2shadow 119 119 res 5, a ··· 135 135 push hl 136 136 call _delay ; delay 3 seconds 137 137 pop hl 138 - ld a, #0x05 139 - out (#0x06), a ; switch slot4000device to modem 138 + ld a, #DEVICE_MODEM 139 + out (#SLOT_DEVICE), a ; switch slot device to modem 140 140 ld a, #0b11000111 ; 14 byte FIFO 141 - ld (#0x4002), a ; FCR = enable FIFO 141 + ld (#SLOT_ADDR + 0x2), a ; FCR = enable FIFO 142 142 ld a, #0b10000011 143 - ld (#0x4003), a ; LCR = DLAB=1, 8n1 143 + ld (#SLOT_ADDR + 0x3), a ; LCR = DLAB=1, 8n1 144 144 xor a 145 - ld (#0x4001), a ; DLM = 0 145 + ld (#SLOT_ADDR + 0x1), a ; DLM = 0 146 146 determine_dlab: 147 147 dlab_57600: 148 148 ld hl, (_setting_modem_speed) ··· 224 224 add hl, de 225 225 jr c, dlab_default 226 226 ld a, #0x01 227 - ld (#0x4001), a ; DLM = 0x1 227 + ld (#SLOT_ADDR + 0x1), a ; DLM = 0x1 228 228 ld a, #0x80 ; DLL = 0x80, baud rate = 300 229 229 jr set_dlab 230 230 dlab_default: ··· 232 232 ld (_setting_modem_speed), hl 233 233 jp determine_dlab ; run through the loop again 234 234 set_dlab: 235 - ld (#0x4000), a ; DLL 235 + ld (#SLOT_ADDR), a ; DLL 236 236 ld a, #0b00000011 237 - ld (#0x4003), a ; LCR = DLAB=0, 8n1 238 - ld a, (#0x4004) ; read MCR 237 + ld (#SLOT_ADDR + 0x3), a ; LCR = DLAB=0, 8n1 238 + ld a, (#SLOT_ADDR + 0x4) ; read MCR 239 239 or #0b00001011 240 - ld (#0x4004), a ; MCR = DTR, RTS, HINT 240 + ld (#SLOT_ADDR + 0x4), a ; MCR = DTR, RTS, HINT 241 241 ld b, #0x01 242 242 ld c, #0x06 243 243 ; call 0x0a2f ; jp 0x1afb, do something with port 3 244 244 ; call 0x33ca ; init modem vars, activate interrupts 245 245 ld a, #0b00001001 ; IER = EDSSI, ERBFI 246 - ld (#0x4001), a 247 - ld a, (#0x4006) 246 + ld (#SLOT_ADDR + 0x1), a 247 + ld a, (#SLOT_ADDR + 0x6) 248 248 ld (_modem_curmsr), a ; read and store MSR 249 249 pop af 250 - out (#0x06), a ; restore old slot4000device 250 + out (#SLOT_DEVICE), a ; restore old slot device 251 251 pop hl 252 252 pop bc 253 253 ret ··· 257 257 ; return a byte in hl from the modem FIFO, from 0x3328 in v2.54 firmware 258 258 _modem_read:: 259 259 ; use hl 260 - in a, (0x06) ; save old slot4000device 260 + in a, (#SLOT_ADDR) ; save old slot device 261 261 ld h, a ; into h 262 - ld a, #0x05 263 - out (0x06),a ; slot4000device = modem 264 - ld a, (0x4000) ; read byte from modem 262 + ld a, #DEVICE_MODEM 263 + out (#SLOT_DEVICE), a ; slot device = modem 264 + ld a, (#SLOT_ADDR) ; read byte from modem 265 265 ld l, a ; into l 266 266 ld a, h 267 - out (0x06), a ; set old slot4000device 267 + out (#SLOT_DEVICE), a ; set old slot device 268 268 ld h, #0x00 269 269 ret ; return hl 270 270 ··· 278 278 push hl 279 279 ld a, 4(ix) 280 280 ld l, a 281 - in a, (0x06) 281 + in a, (#SLOT_DEVICE) 282 282 ld h, a 283 - ld a, #0x05 284 - out (0x06), a 283 + ld a, #DEVICE_MODEM 284 + out (#SLOT_DEVICE), a 285 285 ld a, l 286 - ld (0x4000), a 286 + ld (#SLOT_ADDR), a 287 287 ld a, h 288 - out (0x06), a 288 + out (#SLOT_DEVICE), a 289 289 pop hl 290 290 pop ix 291 291 ret ··· 294 294 ; int modem_ier(void) 295 295 ; return modem IER register in hl, from 0x3339 in v2.54 firmware 296 296 _modem_ier:: 297 - in a, (0x06) 297 + in a, (#SLOT_DEVICE) 298 298 ld h, a 299 - ld a, #0x05 300 - out (0x06), a 301 - ld a, (0x4001) ; read modem IER 299 + ld a, #DEVICE_MODEM 300 + out (#SLOT_DEVICE), a 301 + ld a, (#SLOT_ADDR + 0x1) ; read modem IER 302 302 ld l, a 303 303 ld a, h 304 - out (0x06), a 304 + out (#SLOT_DEVICE), a 305 305 ld h, #0x0 306 306 ret 307 307 ··· 309 309 ; int modem_iir(void) 310 310 ; return modem IIR register in hl, from 0x334a in v2.54 firmware 311 311 _modem_iir:: 312 - in a, (0x06) 312 + in a, (#SLOT_DEVICE) 313 313 ld h, a 314 - ld a, #0x05 315 - out (0x06), a 316 - ld a, (0x4002) ; read modem IIR 314 + ld a, #DEVICE_MODEM 315 + out (#SLOT_DEVICE), a 316 + ld a, (#SLOT_ADDR + 0x2) ; read modem IIR 317 317 ld l, a 318 318 ld a, h 319 - out (0x06), a 319 + out (#SLOT_DEVICE), a 320 320 ld h, #0x0 321 321 ret 322 322 ··· 324 324 ; int modem_lcr(void) 325 325 ; return modem LCR register in hl 326 326 _modem_lcr:: 327 - in a, (0x06) 327 + in a, (#SLOT_DEVICE) 328 328 ld h, a 329 - ld a, #0x05 330 - out (0x06), a 331 - ld a, (0x4003) ; read LCR 329 + ld a, #DEVICE_MODEM 330 + out (#SLOT_DEVICE), a 331 + ld a, (#SLOT_ADDR + 0x3) ; read LCR 332 332 ld l, a 333 333 ld a, h 334 - out (0x06), a 334 + out (#SLOT_DEVICE), a 335 335 ld h, #0x00 336 336 ret 337 337 ··· 339 339 ; int modem_lsr(void) 340 340 ; return modem LSR register in hl 341 341 _modem_lsr:: 342 - in a, (0x06) 342 + in a, (#SLOT_DEVICE) 343 343 ld h, a 344 - ld a, #0x05 345 - out (0x06), a 346 - ld a, (0x4005) ; read LSR 344 + ld a, #DEVICE_MODEM 345 + out (#SLOT_DEVICE), a 346 + ld a, (#SLOT_ADDR + 0x5) ; read LSR 347 347 ld l, a 348 348 ld a, h 349 - out (0x06), a 349 + out (#SLOT_DEVICE), a 350 350 ld h, #0x00 351 351 ret 352 352 ··· 354 354 ; int modem_msr(void) 355 355 ; return modem MSR register in hl 356 356 _modem_msr:: 357 - in a, (0x06) 357 + in a, (#SLOT_DEVICE) 358 358 ld h, a 359 - ld a, #0x05 360 - out (0x06), a 361 - ld a, (0x4006) ; read modem MSR 359 + ld a, #DEVICE_MODEM 360 + out (#SLOT_DEVICE), a 361 + ld a, (#SLOT_ADDR + 0x6) ; read modem MSR 362 362 ld l, a 363 363 ld a, h 364 - out (0x06), a 364 + out (#SLOT_DEVICE), a 365 365 ld h, #0x0 366 366 ret 367 367 ··· 369 369 ; drop DTR to force a hangup 370 370 _modem_hangup:: 371 371 push hl 372 - in a, (0x06) 372 + in a, (#SLOT_DEVICE) 373 373 ld h, a 374 - ld a, #0x05 375 - out (0x06), a 376 - ld a, (0x4004) ; read modem MCR 374 + ld a, #DEVICE_MODEM 375 + out (#SLOT_DEVICE), a 376 + ld a, (#SLOT_ADDR + 0x4) ; read modem MCR 377 377 res 0, a ; drop DTR 378 - ld (0x4004), a 378 + ld (#SLOT_ADDR + 0x4), a 379 379 push af 380 380 push hl 381 381 ld hl, #500 382 382 push hl 383 - call _delay 383 + call _delay ; sleep 500ms 384 384 pop hl 385 385 pop hl 386 386 pop af 387 387 set 0, a ; restore DTR 388 - ld a, (0x4006) 388 + ld a, (#SLOT_ADDR + 0x6) 389 389 ld (_modem_curmsr), a 390 - ld (0x4004), a 391 - ld a, (0x4006) 390 + ld (#SLOT_ADDR + 0x4), a 391 + ld a, (#SLOT_ADDR + 0x6) 392 392 ld (_modem_curmsr), a 393 393 ld a, h 394 - out (0x06), a 394 + out (#SLOT_DEVICE), a 395 + pop hl 396 + ret 397 + 398 + ; void modem_pause(void) 399 + ; send XOFF 400 + _modem_pause:: 401 + push hl 402 + ld l, #XOFF 403 + push hl 404 + call _modem_write 405 + pop hl 406 + pop hl 407 + ld a, #0 408 + ld (_modem_flowing), a 409 + ret 410 + 411 + ; void modem_unpause(void) 412 + ; send XON 413 + _modem_unpause:: 414 + push hl 415 + ld l, #XON 416 + push hl 417 + call _modem_write 418 + pop hl 395 419 pop hl 396 420 ret
+26 -30
putchar.s
··· 54 54 .db #0 55 55 56 56 57 - .area _GSINIT 58 - 59 - call _clear_screen 60 - 61 57 .area _CODE 62 58 63 59 ; void lcd_cas(unsigned char col) ··· 90 86 push bc 91 87 push de 92 88 push hl 93 - in a, (#06) 94 - ld h, a ; slot4000 device 95 - in a, (#05) 96 - ld l, a ; slot4000 page 89 + in a, (#SLOT_DEVICE) 90 + ld h, a 91 + in a, (#SLOT_PAGE) 92 + ld l, a 97 93 ld a, #DEVICE_LCD_RIGHT 98 - out (#06), a 94 + out (#SLOT_DEVICE), a 99 95 push hl 100 96 call _clear_lcd_half 101 97 ld a, #DEVICE_LCD_LEFT 102 - out (#06), a 98 + out (#SLOT_DEVICE), a 103 99 call _clear_lcd_half 104 100 pop hl 105 101 ld a, h 106 - out (#06), a 102 + out (#SLOT_DEVICE), a 107 103 ld a, l 108 - out (#05), a 104 + out (#SLOT_PAGE), a 109 105 reset_cursor: 110 106 xor a 111 107 ld (_cursorx), a ··· 134 130 135 131 136 132 ; void clear_lcd_half(void) 137 - ; zero out the current LCD module (must already be in slot4000device) 133 + ; zero out the current LCD module (must already be in SLOT_DEVICE) 138 134 ; from v2.54 firmware at 0x2490 139 135 _clear_lcd_half:: 140 136 push bc ··· 212 208 push bc 213 209 push de 214 210 push hl 215 - in a, (#06) 216 - ld h, a ; slot4000 device 217 - in a, (#05) 218 - ld l, a ; slot4000 page 211 + in a, (#SLOT_DEVICE) 212 + ld h, a 213 + in a, (#SLOT_PAGE) 214 + ld l, a 219 215 push hl 220 216 ld a, #DEVICE_LCD_LEFT 221 - out (#06), a 217 + out (#SLOT_DEVICE), a 222 218 call _scroll_lcd_half 223 219 ld a, #DEVICE_LCD_RIGHT 224 - out (#06), a 220 + out (#SLOT_DEVICE), a 225 221 call _scroll_lcd_half 226 222 pop hl 227 223 ld a, h 228 - out (#06), a 224 + out (#SLOT_DEVICE), a 229 225 ld a, l 230 - out (#05), a 226 + out (#SLOT_PAGE), a 231 227 shift_bufs: 232 228 ld b, #0 233 229 screenbuf_shift_loop: ··· 379 375 ld hl, #-15 ; stack bytes for local storage 380 376 add hl, sp 381 377 ld sp, hl 382 - in a, (#06) 383 - ld -3(ix), a ; stack[-3] = slot4000 device 384 - in a, (#05) 385 - ld -4(ix), a ; stack[-4] = slot4000 page 378 + in a, (#SLOT_DEVICE) 379 + ld -3(ix), a ; stack[-3] = old slot device 380 + in a, (#SLOT_PAGE) 381 + ld -4(ix), a ; stack[-4] = old slot page 386 382 find_char: 387 383 ld h, 4(ix) 388 384 ld l, 6(ix) ··· 475 471 rightside: 476 472 ld a, #DEVICE_LCD_RIGHT 477 473 swap_lcd: 478 - out (#06), a 474 + out (#SLOT_DEVICE), a 479 475 ld e, #FONT_WIDTH ; for (col = FONT_WIDTH; col > 0; col--) 480 476 next_char_col: ; inner loop, each col of each row 481 477 ld -14(ix), #0b00011111 ; font data mask that will get shifted ··· 556 552 dec d 557 553 jp nz, next_char_row 558 554 stamp_char_out: 559 - ld a, -3(ix) ; restore slot4000device 560 - out (#06), a 561 - ld a, -4(ix) ; restore slot4000page 562 - out (#05), a 555 + ld a, -3(ix) ; restore old slot device 556 + out (#SLOT_DEVICE), a 557 + ld a, -4(ix) ; restore old slot page 558 + out (#SLOT_PAGE), a 563 559 ld hl, #15 ; remove stack bytes 564 560 add hl, sp 565 561 ld sp, hl
+40 -37
settings.s
··· 23 23 24 24 .include "mailstation.inc" 25 25 26 + .equ SDP_LOCK, #SLOT_ADDR + 0x040a 27 + .equ SDP_UNLOCK, #SLOT_ADDR + 0x041a 28 + 26 29 .equ settings_ident_0, 'j' 27 30 .equ settings_ident_1, 'c' 28 31 .equ settings_ident_2, 's' ··· 46 49 push bc 47 50 push de 48 51 push hl 49 - in a, (#06) ; store device and page 52 + in a, (#SLOT_DEVICE) ; store device and page 50 53 ld h, a 51 - in a, (#05) 54 + in a, (#SLOT_PAGE) 52 55 ld l, a 53 56 push hl 54 57 ld a, #DEVICE_DATAFLASH ; slot 4 device = dataflash 55 - out (#06), a 58 + out (#SLOT_DEVICE), a 56 59 ld a, #settings_page 57 - out (#05), a 58 - ld hl, #0x4000 + (settings_sector * 256) 60 + out (#SLOT_PAGE), a 61 + ld hl, #SLOT_ADDR + (settings_sector * 256) 59 62 push hl 60 63 ld a, (hl) 61 64 cp #settings_ident_0 ; verify that the first 3 bytes are ··· 78 81 pop hl 79 82 pop hl 80 83 ld a, h 81 - out (#06), a 84 + out (#SLOT_DEVICE), a 82 85 ld a, l 83 - out (#05), a 86 + out (#SLOT_PAGE), a 84 87 pop hl 85 88 pop de 86 89 pop bc 87 90 ret 88 91 92 + sdp: 93 + ld a, (#SLOT_ADDR + 0x1823) ; 28SF040 Software Data Protection 94 + ld a, (#SLOT_ADDR + 0x1820) 95 + ld a, (#SLOT_ADDR + 0x1822) 96 + ld a, (#SLOT_ADDR + 0x0418) 97 + ld a, (#SLOT_ADDR + 0x041b) 98 + ld a, (#SLOT_ADDR + 0x0419) 99 + ret 100 + ; caller needs to read final SDP_LOCK or SDP_UNLOCK address 101 + 89 102 ; void settings_write(void) 90 103 _settings_write:: 91 104 push bc 92 105 push de 93 106 push hl 94 - in a, (#06) ; store device and page 107 + in a, (#SLOT_DEVICE) ; store device and page 95 108 ld h, a 96 - in a, (#05) 109 + in a, (#SLOT_PAGE) 97 110 ld l, a 98 111 push hl 99 112 ld a, #DEVICE_DATAFLASH ; slot 4 device = dataflash 100 - out (#06), a 113 + out (#SLOT_DEVICE), a 101 114 xor a 102 - out (#05), a ; slot 4 page = 0 103 - ld a, (#0x5823) ; Software Data Protection unprotect 104 - ld a, (#0x5820) 105 - ld a, (#0x5822) 106 - ld a, (#0x4418) 107 - ld a, (#0x441b) 108 - ld a, (#0x4419) 109 - ld a, (#0x441a) ; 041a=unlock 040a=lock 115 + out (#SLOT_PAGE), a ; slot 4 page = 0 116 + call sdp 117 + ld a, (#SDP_UNLOCK) 110 118 ld a, #settings_page 111 - out (#05), a 112 - ld hl, #0x4000 + (settings_sector * 256) 119 + out (#SLOT_PAGE), a 120 + ld hl, #SLOT_ADDR + (settings_sector * 256) 113 121 sector_erase: 114 - ld (hl), #0x20 ; sector-erase 115 - ld (hl), #0xd0 122 + ld (hl), #0x20 ; 28SF040 Sector-Erase Setup 123 + ld (hl), #0xd0 ; 28SF040 Execute 116 124 sector_erase_wait: 117 - ld a, (hl) 125 + ld a, (hl) ; wait until End-of-Write 118 126 ld b, a 119 127 ld a, (hl) 120 128 cp b ··· 125 133 byte_program_loop: 126 134 ld a, (de) 127 135 ld c, a 128 - ld (hl), #0x10 ; byte-program setup 129 - ld (hl), c ; write new byte 136 + ld (hl), #0x10 ; 28SF040 Byte-Program Setup 137 + ld (hl), a ; 28SF040 Execute 130 138 byte_program: 131 139 ld a, (hl) 132 140 ld c, a 133 - ld a, (hl) ; end write by reading it 141 + ld a, (hl) ; End-of-Write by reading it 134 142 cp c 135 143 jr nz, byte_program ; read until writing succeeds 136 144 inc hl 137 145 inc de 138 146 djnz byte_program_loop 139 147 flash_lock: 140 - xor a ; slot 4 page = 0 141 - out (#05), a 142 - ld a, (#0x5823) ; Software Data Protection unprotect 143 - ld a, (#0x5820) 144 - ld a, (#0x5822) 145 - ld a, (#0x4418) 146 - ld a, (#0x441b) 147 - ld a, (#0x4419) 148 - ld a, (#0x440a) ; 041a=unlock 040a=lock 148 + xor a ; slot page = 0 149 + out (#SLOT_PAGE), a 150 + call sdp 151 + ld a, (#SDP_LOCK) 149 152 pop hl 150 153 ld a, h 151 - out (#06), a 154 + out (#SLOT_DEVICE), a 152 155 ld a, l 153 - out (#05), a 156 + out (#SLOT_PAGE), a 154 157 pop hl 155 158 pop de 156 159 pop bc