Polish VRAM access to TTY TX emulation

It assumes Apple BASIC's manner of controlling screen.
Apple BASIC may be able to work exactly like running through
a virtual terminal device.
This commit is contained in:
Takashi Toyoshima 2014-12-13 02:32:04 +09:00
parent 35bb8b7083
commit 2d6878d2a7
3 changed files with 48 additions and 14 deletions

View File

@ -5,7 +5,8 @@ LD = arm-none-eabi-ld
OBJCOPY = arm-none-eabi-objcopy
LDSCRIPT= lpc1114.ld
LPC21ISP= lpc21isp
SERIAL = /dev/ttyUSB0
#SERIAL = /dev/ttyUSB0
SERIAL = /dev/ttyUSB1
#SERIAL = /dev/ttyACM0
SPEED = 115200
#SPEED = 9600

View File

@ -164,7 +164,8 @@ cpu6502_load:
orrs r0, r0, r1
ldr r1, =#kbddata
strb r0, [r1]
b 3b
// Drop old input data?
// b 3b
2:
ldr r2, =#kbddata
ldrb r0, [r2]
@ -360,20 +361,18 @@ a2_tty:
strb r0, [r3]
1:
cmp r0, #4
bne 2f
bne 3f
// scrmode 4 (normal)
//cmp r1, #0xff
//bne 1f
//pop {pc}
1:
//cmp r1, #0x7f
//bne 1f
//pop {pc}
1:
movs r3, #0x04
lsls r3, r3, #8
subs r3, r2, r3
movs r2, r3
cmp r2, #0x27
bne 1f
cmp r1, #0xff
beq 2f
1:
movs r0, #0x7f
ands r2, r2, r0
lsrs r3, r3, #7
@ -403,8 +402,42 @@ a2_tty:
1:
mov r0, r1
bl a2_putc
pop {pc}
2:
ldr r0, =#scrmode
movs r1, #5
strb r1, [r0]
3:
cmp r0, #5
bne 2f
// scrmode 5 (Waitinf for scroll finished)
movs r3, #0x07
lsls r3, r3, #8
movs r0, #0xf7
adds r3, r3, r0
cmp r2, r3
beq 1f
pop {pc}
1:
ldr r0, =#scrline
ldrb r0, [r0]
movs r1, #24
subs r1, r0
1:
movs r0, #0x0a
push {r1}
bl uart_putc
pop {r1}
subs r1, r1, #1
bne 1b
ldr r1, =#scrmode
movs r0, #4
strb r0, [r1]
ldr r1, =#scrline
movs r0, #23
strb r0, [r1]
2:
// TODO: scroll
pop {pc}
.bss

6
test.c
View File

@ -45,7 +45,7 @@ uint8_t cpu6502_load(uint16_t addr) {
if (0x0400 <= addr && addr <= 0x7ff) {
// Fake text VRAM.
result = mem[addr];
result = '@';
result = 0xff;
} else if ((0x0300 <= addr && addr <= 0x03ff) ||
(0x0900 <= addr && addr <= 0x0fff)) {
// Fake memory impl to make it run on low memory chip.
@ -108,7 +108,7 @@ void cpu6502_store(uint16_t addr, uint8_t data) {
// clear x, y
// 2) Show "APPLE ][" from back to forth.
// 3) Count down from G to A at x = 40, y = 23
// 4) Scroll happens on CR at line 22 or 23, left to right, up to down
// 4) Scroll happens on CR at line 22 or 23, right to left, up to down
// for (var y = 0; y < 23; ++y)
// for (var x = 39; x >= 0; --x)
// reset x, y
@ -116,7 +116,7 @@ void cpu6502_store(uint16_t addr, uint8_t data) {
// clear x, 23
// prompt 0, 23
//fprintf(stdout, "\e[%d;%dH%c", y + 7, x + 1, ascii[data & 0x3f]);
fprintf(stdout, "(%2d,%2d)%c($%02x)\n", x, y, ascii[data & 0x3f], data);
fprintf(stdout, "(%2d,%2d)@%04x%c($%02x)\n", x, y, addr, ascii[data & 0x3f], data);
fflush(stdout);
} else if ((0x0300 <= addr && addr <= 0x03ff) ||
(0x0900 <= addr && addr <= 0x0fff)) {