PR#3 PREFIX /A2OSX.SRC NEW INC 1 AUTO 6 .LIST OFF .OP 65C02 .OR $2000 .TF /A2OSX.BOOT/DRV/DHGR.DRV *-------------------------------------- .INB INC/MACROS.I .INB INC/A2OSX.I .INB INC/IO.I .INB INC/LIBGFX.I *-------------------------------------- ZPBase .EQ ZPDRV ZPShiftLo .EQ ZPDRV+2 ZPShiftHi .EQ ZPDRV+4 ZPCtrlBlk .EQ ZPDRV+8 limited to 8 bytes for now...have to modify kernel *-------------------------------------- * File Header (16 Bytes) *-------------------------------------- CS.START cld jmp Dev.Detect cld,jmp abs=DRV .DA #$61 6502,Level 1 (65c02) .DA #1 DRV Layout Version 1 .DA 0 .DA CS.END-CS.START Code Length .DA DEV.HEADER-CS.START Device Header Offset .DA DRV.CS.START-CS.START Driver Code Offset .DA DRV.CS.END-DRV.CS.START Drv Code Length *-------------------------------------- * Relocation Table *-------------------------------------- L.MSG.DETECT .DA MSG.DETECT .DA 0 End Of Reloc Table *-------------------------------------- Dev.Detect >LDYA L.MSG.DETECT >SYSCALL PrintFYA ldx #0 .1 txa stz Shift0.hi,x asl rol Shift0.hi,x lsr sta Shift0.lo,x inx bpl .1 ldx #0 .2 lda Shift0.hi,x sta Shift1.hi,x lda Shift0.lo,x asl asl rol Shift1.hi,x lsr sta Shift1.lo,x inx bpl .2 ldx #0 .3 lda Shift1.hi,x sta Shift2.hi,x lda Shift1.lo,x asl asl rol Shift2.hi,x lsr sta Shift2.lo,x inx bpl .3 ldx #0 .4 lda Shift2.hi,x sta Shift3.hi,x lda Shift2.lo,x asl asl rol Shift3.hi,x lsr sta Shift3.lo,x inx bpl .4 ldx #0 .5 lda Shift3.hi,x sta Shift4.hi,x lda Shift3.lo,x asl asl rol Shift4.hi,x lsr sta Shift4.lo,x inx bpl .5 ldx #0 .6 lda Shift4.hi,x sta Shift5.hi,x lda Shift4.lo,x asl asl rol Shift5.hi,x lsr sta Shift5.lo,x inx bpl .6 ldx #0 .7 lda Shift5.hi,x sta Shift6.hi,x lda Shift5.lo,x asl asl rol Shift6.hi,x lsr sta Shift6.lo,x inx bpl .7 clc rts CS.END MSG.DETECT >CSTR "\nApple IIe/IIc DHGR Driver.\n" *-------------------------------------- * Device Header (16 Bytes) *-------------------------------------- DEV.HEADER cld jmp (DRV.CS.START,x) .HS 00 DevID .DA #0 No Flag >PSTR "GFX" NAME .HS 00 NAME must Be 5 bytes long .HS 00 .HS 00.00.00.00 *-------------------------------------- * Driver Code *-------------------------------------- DRV.CS.START .DA OPEN .DA GETEVENT .DA COUT .DA CLOSE .DA GETINFO .DA IRQ .DA SELECT .DA SETPIXEL .DA GETPIXEL .DA HLINE .DA VLINE .DA BITBLT .DA FILLREC .DA SETCURPOS .DA SETCUR .DA HIDECUR .DA SHOWCUR L.DEVINFO .DA DEVINFO L.DIV7.0 .DA DIV7.0 L.MOD7.0 .DA MOD7.0 L.Shift0.Lo .DA Shift0.lo L.Shift0.Hi .DA Shift0.hi .DA 0 end or relocation *-------------------------------------- OPEN ldy #S.DEV.ID lda (pDev),y sta A2osX.SCRNDEVS+2 lda #3 sta A2osX.ASCREEN jsr SELECT lda L.DIV7.0+1 sta DIV7.hi inc sta DIV7.hi+1 inc sta DIV7.hi+2 ldy #0 ldx #0 .1 lda L.MOD7.0,y sta MOD7.lo,x iny lda L.MOD7.0,y sta MOD7.hi,x iny inx cpx #3 bne .1 ldx #7 lda L.Shift0.Lo+1 .10 sta Shiftlo.hi,x inc dex bne .10 ldx #7 lda L.Shift0.hi+1 .11 sta Shifthi.hi,x inc dex bne .11 .8 clc rts *-------------------------------------- GETEVENT COUT IRQ sec rts *-------------------------------------- CLOSE clc rts *-------------------------------------- GETINFO >LDYA L.DEVINFO clc rts *-------------------------------------- SELECT sta CLRTEXT sta CLRMIXED sta SETHIRES sta CLR80STORE sta CLRPAGE2 sta SETIOUDIS sta SETDHIRES * sta CLR80DISP * sta SETDHIRES * sta CLRDHIRES * sta SET80DISP * sta SETDHIRES * sta CLRDHIRES * sta SETDHIRES clc rts *-------------------------------------- * SETPIXEL * In : YA = Ptr to CtrlBlk : * 0 : X * 2 : Y * 4 : Mode * 00000000=xor * 00000001=b/w (1 bit/pixel) * 00000100=16 colors (4 bits/pixel) * 00001000=256 colors (8 bits/pixel) * 5 : Color *-------------------------------------- SETPIXEL >STYA ZPBase ldy #5 .1 lda (ZPBase),y sta ZPCtrlBlk,y dey bpl .1 sta SET80STORE lda ZPCtrlBlk+4 bit #%00000100 bne .7 *-----B&W ----------------------------- ldx ZPCtrlBlk+1 X.HI lda DIV7.hi,x sta .2+2 lda MOD7.lo,x sta .4+1 lda MOD7.hi,x sta .4+2 ldx ZPCtrlBlk X.LO .2 lda DIV7.0,x A=Col*2+AuxBit eor #1 toggle last bit : 0=Aux, 1=Main lsr .3+1 reset CLRPAGE2 address lsr CS=Aux rol .3+1 if CS, -> SETPAGE2 .3 sta CLRPAGE2 adc BASEL,y setup line Base Ptr (A=Col) sta ZPBase lda BASEH,y sta ZPBase+1 .4 ldy MOD7.0,x x = X.LO dec ZPCtrlBlk+4 get mode bne .5 lda (ZPBase) Mode=0, XOR eor Mono.Masks,y y = mod 7 sta (ZPBase) sta CLR80STORE rts .5 lda (ZPBase) ldx ZPCtrlBlk+5 mode=1, get color bne .6 and Mono.NMasks,y includes And $7F for mono sta (ZPBase) sta CLR80STORE rts .6 and #$7F switch back this byte to mono ora Mono.Masks,y sta (ZPBase) sta CLR80STORE rts *-----16 Colors ----------------------- .7 lda ZPCtrlBlk X.LO lsr ZPCtrlBlk+1 divide by 4 ror lsr ZPCtrlBlk+1 ror tay Y=CX/4 (range 0->139) lda DIV7.0,y A=CX/4/7 (range 0->19) asl times 2 (range 0->38) ldx ZPCtrlBlk+2 adc BASEL,x setup line Base Ptr (cc by asl) sta ZPBase ZPBase now point to first of... lda BASEH,x sta ZPBase+1 ...the 4 columns lda MOD7.0,y get MOD asl times 4 to compute index in MASK tables asl tax set in X for Masks,NMasks lda ZPCtrlBlk+5 get COLOR asl times 4 to compute index in PIXELS table asl tay lda Color.Masks,x bits in 1st byte to light? beq .10 and Color.Pixels,y apply color sta GBYTE sta SETPAGE2 lda (ZPBase) and Color.NMasks,x reset existing pixel, ora GBYTE sta (ZPBase) .10 inx iny lda Color.Masks,x beq .11 and Color.Pixels,y apply color sta GBYTE sta CLRPAGE2 lda (ZPBase) and Color.NMasks,x reset existing pixel, ora GBYTE sta (ZPBase) .11 inc ZPBase inx iny lda Color.Masks,x beq .12 and Color.Pixels,y apply color sta GBYTE sta SETPAGE2 lda (ZPBase) and Color.NMasks,x reset existing pixel, ora GBYTE sta (ZPBase) .12 inx iny lda Color.Masks,x beq .13 and Color.Pixels,y apply color sta GBYTE sta CLRPAGE2 lda (ZPBase) and Color.NMasks,x reset existing pixel, ora GBYTE sta (ZPBase) .13 sta CLR80STORE rts *-------------------------------------- GETPIXEL rts *-------------------------------------- HLINE rts *-------------------------------------- VLINE rts *-------------------------------------- FILLREC rts *-------------------------------------- * BitBlt * In : YA = Ptr to CtrlBlk : * 0 : Operation * %00000001 : Save * %00000010 : Replace * %00000100 : AND with Src BitMask * %00001000 : ORA with Src BitMap * %00010000 : XOR * 2 : SavePTR * 4 : SrcAX * 6 : SrcAY * 8 : SrcBX * 10 : SrcBY * 12 : DestX * 14 : DestY * 16 : BM Struct *-------------------------------------- BITBLT >STYA ZPCtrlBlk lda (ZPCtrlBlk) clc rts *-------------------------------------- * Y,A = pPoint *-------------------------------------- SETCURPOS >STYA ZPBase ldy #3 .1 lda (ZPBase),y sta CUR.X,y dey bpl .1 bit CUR.State bpl .2 jsr HIDECUR.I jsr SHOWCUR.I .2 clc rts *-------------------------------------- * Y,A = pCur *-------------------------------------- SETCUR >STYA ZPBase ldy #S.CUR-1 .1 lda (ZPBase),y sta CUR.Buf,y dey bpl .1 bit CUR.State bpl .2 jsr HIDECUR.I jsr SHOWCUR.I .2 clc rts *-------------------------------------- SHOWCUR bit CUR.State bpl SHOWCUR.I clc rts SHOWCUR.I sta SET80STORE ldx CUR.X+1 lda DIV7.hi,x sta .71+2 lda MOD7.hi,x sta .72+2 ldx CUR.X .71 lda DIV7.0,x lsr sta SB.StartCol lda #0 sbc #0 sta SB.StartPage .72 ldy MOD7.0,x lda Shiftlo.Hi,y sta ZPShiftLo+1 lda ShiftHi.Hi,y sta ZPShiftHi+1 lda L.Shift0.Lo sta ZPShiftLo lda L.Shift0.hi sta ZPShifthi lda CUR.Y sta CY ldx #0 index to CUR data/mask .1 ldy CY lda BaseL,y clc adc SB.StartCol sta ZPBase lda BaseH,y sta ZPBase+1 lda SB.StartPage sta SB.Page lda SB.Page tay eor #1 sta SB.Page sta CLRPAGE2,y lda (ZPBase) ldy CUR.Buf+S.CUR.MASK,x and (ZPShiftLo),y ldy CUR.Buf+S.CUR.DATA,x ora (ZPShiftLo),y sta (ZPBase) lda SB.Page tay eor #1 sta SB.Page sta CLRPAGE2,y beq .3 inc ZPBase .3 lda (ZPBase) ldy CUR.Buf+S.CUR.MASK,x and (ZPShiftHi),y ldy CUR.Buf+S.CUR.DATA,x ora (ZPShiftHi),y inx ldy CUR.Buf+S.CUR.MASK,x and (ZPShiftLo),y ldy CUR.Buf+S.CUR.DATA,x ora (ZPShiftLo),y sta (ZPBase) lda SB.Page tay eor #1 sta SB.Page sta CLRPAGE2,y beq .4 inc ZPBase .4 lda (ZPBase) ldy CUR.Buf+S.CUR.MASK,x and (ZPShiftHi),y ldy CUR.Buf+S.CUR.DATA,x ora (ZPShiftHi),y sta (ZPBase) inx cpx #32 bne .1 sta CLR80STORE sec ror CUR.State SHOWCUR.RTS clc rts *-------------------------------------- HIDECUR bit CUR.State bpl HIDECUR.RTS HIDECUR.I clc ror CUR.State HIDECUR.RTS clc rts *-------------------------------------- DRV.CS.END *-------------------------------------- Shift0.lo .BS 128 Shift0.hi .BS 128 Shift1.lo .BS 128 Shift1.hi .BS 128 Shift2.lo .BS 128 Shift2.hi .BS 128 Shift3.lo .BS 128 Shift3.hi .BS 128 Shift4.lo .BS 128 Shift4.hi .BS 128 Shift5.lo .BS 128 Shift5.hi .BS 128 Shift6.lo .BS 128 Shift6.hi .BS 128 *-------------------------------------- .INB DRV/DHGR.DRV.T *-------------------------------------- DIV7.hi .BS 3 MOD7.lo .BS 3 MOD7.hi .BS 3 Shiftlo.hi .BS 7 Shifthi.hi .BS 7 *-------------------------------------- CX .BS 2 CY .BS 1 COL .BS 1 GBYTE .BS 1 *-------------------------------------- CUR.State .BS 1 CUR.X .BS 2 CUR.Xdiv7 .BS 1 CUR.Xmod7 .BS 1 CUR.Y .BS 2 CUR.Buf .BS S.CUR CUR.SaveCol .BS 1 CUR.SaveColCnt .BS 1 CUR.SaveRow .BS 1 CUR.SaveRowCnt .BS 1 CUR.SaveBuf .BS 3*16 MAX 3 bytes*16 rows SB.StartPage .BS 1 SB.Page .BS 1 SB.StartCol .BS 1 SB.Col .BS 1 *-------------------------------------- DEVINFO .DA #S.DEVINFO.TYPE.GFX type of DEVINFO STRUCT DEVINFO.MODES .DA #%10000011 XOR,16 & B/W DEVINFO.W .DA 560 X.SIZE DEVINFO.H .DA 192 Y.SIZE .LIST ON *-------------------------------------- DRV.SIZE .EQ *-DRV.CS.START *-------------------------------------- .LIST OFF MAN SAVE DRV/DHGR.DRV.S ASM