TRS80 Model 4/4P
(or right now more accurately sdltrs/xtrs)
+This port supports the following configurations currently
+
+ TRS80 Model 4/4P (including gate array floppy disk workarounds)
+ Options:
+ Floppy Disk (somewhat basic support, no format tool yet)
+ Hard Disk (Tandy compatible)
+ Dave Huffman style banked memory (on Port 0x94)
+ In Progress:
+ Tandy hi-res graphics
+ Orchestra 90 sound card
+ Planned:
+ Micro Labs Grafyx
+ Alpha Joystick
+ IDE adapter
+ Not Supported:
+ XLR8R - to do it well is a different port
+
+
Requres:
Patched xtrs from Fuzix git tree
32,
GFX_DRAW|GFX_READ|GFX_WRITE
}
+ /* FIXME: Need to add Micrographyx at some point (needs a different id to
+ the TRS80 model III one */
};
/* Assumes a Tandy board */
static uint8_t vmode;
-static int gfx_draw_op(uarg_t arg, char *ptr, uint8_t *buf)
-{
- int l;
- int c = 8; /* 4 x uint16_t */
- uint16_t *p = (uint16_t *)buf;
- l = ugetw(ptr);
- if (l < 6 || l > 512)
- return EINVAL;
- if (arg != GFXIOC_READ)
- c = l;
- if (uget(buf, ptr + 2, c))
- return EFAULT;
- switch(arg) {
- case GFXIOC_DRAW:
- /* TODO
- if (draw_validate(ptr, l, 1024, 256))
- return EINVAL */
- video_cmd(buf);
- break;
- case GFXIOC_WRITE:
- case GFXIOC_READ:
- case GFXIOC_EXG:
- if (l < 8)
- return EINVAL;
- l -= 8;
- if (p[0] > 128 || p[1] > 255 || p[2] > 128 || p[3] > 255 ||
- p[0] + p[2] > 128 || p[1] + p[3] > 255 ||
- (p[2] * p[3]) > l)
- return -EFAULT;
- if (arg == GFXIOC_WRITE)
- video_write(buf);
- else {
- if (arg == GFXIOC_READ)
- video_read(buf);
- else
- video_exg(buf);
- if (uput(buf + 10, ptr, l - 2))
- return EFAULT;
- return 0;
- }
- }
- return 0;
-}
-
int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr)
{
uint8_t m;
if (vmode == 0)
break;
return uput(&trsmap, ptr, sizeof(trsmap));
- case GFXIOC_DRAW:
- case GFXIOC_READ:
- case GFXIOC_WRITE:
- case GFXIOC_EXG:
- if (vmode == 1) {
- uint8_t *tmp = (uint8_t *)tmpbuf();
- err = gfx_draw_op(arg, ptr, tmp);
- tmpfree(tmp);
- if (err) {
- udata.u_error = err;
- err = -1;
- }
- return err;
- }
- /* Fall through */
}
return -1;
}
; and the page from the C code
.globl _hd_page
- ; video
- .globl _video_cmd
- .globl _video_read
- .globl _video_write
- .globl _video_exg
-
; exported debugging tools
.globl _platform_monitor
.globl _platform_reboot
call map_kernel
ret
-;
-; Graphics card
-;
-_video_cmd:
- pop de
- pop hl
- push hl
- push de
- ld e,(hl) ; X byte, Y line
- inc hl ; The hardware does the conversion
- inc hl
- ld d,(hl) ; for us
- inc hl ; skip high bytes
- inc hl
- ld a, #0x43 ; auto incremeent X on write only
- out (0x83), a ; set the register up
-nextline:
- push de
- ld c, #0x80
- out (c), e ; X
- inc c
- out (c), d ; Y
-nextop:
- xor a
- ld b, (hl)
- cp b
- jr z, endline
- inc hl
- ld c,(hl)
- inc hl
-oploop:
- in a, (0x82) ; read data
- and c
- xor (hl)
- out (0x82), a ; autoincrements X
- djnz oploop
- inc hl
- jr nextop
-endline: pop de
- inc d ; down a scan line (easy peasy)
- inc hl
- xor a
- cp (hl) ; 0 0 = end (for blank lines just do 01 ff 00)
- jr nz, nextline
- ret
-
-_video_write:
- ld a, #0xB3
- ld (patch_io + 1), a ; OTIR
- ld a, #0x43
-video_do:
- out (0x83), a ; autoincrement on write
- pop de
- pop iy
- push iy
- push de
- push iy
- pop hl
- ld de, #8
- add hl, de ; Data start into HL
- ld e, (iy) ; x
- ld d, 2(iy) ; y
-next_rw:
- ld c, #0x80
- out (c), e ; x
- inc c
- out (c), d ; y
- inc c ; to data
- ld b, 4(iy) ; count of bytes per line
-patch_io:
- otir ; wheee...
- inc d ; next line
- dec 6(iy) ; height
- jr nz, next_rw
- ret
-
-_video_read:
- ld a, #0xB2 ; inir
- ld (patch_io + 1), a
- ld a, #0x13 ; autoincrement on read
- jr video_do
-
-_video_exg: ; not quite worth self modifying
- ld a, #0xB3 ; this one too
- ld (patch_io + 1), a ; OTIR
- ld a, #0x43
- out (0x83), a ; autoincrement on write
- pop de
- pop iy
- push iy
- push de
- push iy
- pop hl
- ld de, #8
- add hl, de ; Data start into HL
- ld e, (iy) ; x
- ld d, 2(iy) ; y
-next_ex:
- ld c, #0x80
- out (c), e ; x
- inc c
- out (c), d ; y
- ld b, 4(iy) ; count of bytes per line
-ex_line:
- in a, (0x82) ; faster than in a,(c)
- ex af,af' ; icky but no free registers
- ld a, (hl)
- out (0x82), a ; write and inc
- ex af, af
- ld (hl), a
- inc hl
- djnz ex_line
- inc d ; next line
- dec 6(iy) ; height
- jr nz, next_ex
- ret