; rocks.as - overscan example in GRAPHIC 3 mode ; Copyright (C) 2000 ag0ny@ag0ny.com ; ********************* ; **** Definitions **** ; ********************* ; RAM copy of VDP registers. ; vdpregs0 -> R#0..R#7 ; vdpregs1 -> R#8..R#23 ; vdpregs0 equ 0f3dfh vdpregs1 equ 0ffe7h-8 ; VDP ports ; vdpport0 equ 098h ; VRAM read/write vdpport1 equ 099h ; VDP registers read/write vdpport2 equ 09ah ; Palette registers write vdpport3 equ 09bh ; Indirect register write ; Other ; TAB_NAME equ 01800h ; GRAPHIC 3 pattern name table TAB_COLOR equ 02000h ; GRAPHIC 3 color table TAB_GENERATOR equ 00000h ; GRAPHIC 3 pattern generator table ; **************** ; **** Macros **** ; **************** ; M_VDP: send value in A to VDP register ; syntax: M_VDP reg# ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_VDP macro reg out (vdpport1),a ld a,reg or 080h out (vdpport1),a endm ; M_VDPST: read VDP status register ; syntax: M_VDPST reg# ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_VDPST macro reg ld a,reg M_VDP 15 ; set VDP status register to read in a,(vdpport1) endm ; M_SVRAM: select VRAM access from the VDP ; syntax: M_SVRAM ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_SVRAM macro ld a,(vdpregs1+45) and 010111111b ld (vdpregs1+45),a M_VDP 45 endm ; M_SXRAM: select expanded RAM access from the VDP ; syntax: M_SXRAM ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_SXRAM macro ld a,(vdpregs1+45) or 001000000b ld (vdpregs1+45),a M_VDP 45 endm ; M_R2V8: copy RAM block to VRAM (up to 256 bytes) (low 64Kb) ; syntax: M_R2V8 ,, ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_R2V8 macro ram,vram,num ld de,vram call setvramaddr_w ld hl,ram ld bc,num*256 + vdpport0 otir endm ; M_R2V16: copy RAM block to VRAM (up to 65536 bytes) (low 64Kb) ; syntax: M_R2V16 ,, ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_R2V16 macro ram,vram,num ld de,vram call setvramaddr_w ld de,num ld hl,ram ld c,vdpport0 ld a,(hl) out (c),a inc hl dec de ld a,d or e jr nz,$-7 endm ; M_192LN: set 192 lines VDP display mode ; syntax: M_192LN ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_192LN macro ld a,(vdpregs1+9) and 001111111b ld (vdpregs1+9),a M_VDP 9 endm ; M_212LN: set 212 lines VDP display mode ; syntax: M_212LN ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_212LN macro ld a,(vdpregs1+9) or 010000000b ld (vdpregs1+9),a M_VDP 9 endm ; M_SPRON: turn ON V9938/V9958 sprites display ; syntax: M_SPRON ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_SPRON macro ld a,(vdpregs0+0) and 011111101b ld (vdpregs0+0),a M_VDP 8 endm ; M_SPROFF: turn OFF V9938/V9958 sprites display ; syntax: M_SPROFF ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_SPROFF macro ld a,(vdpregs0+0) or 000000010b ld (vdpregs0+0),a M_VDP 8 endm ; M_SETINTLN: set line # for vertical scanning interrupt ; syntax: M_SETINTLN line# ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_SETINTLN macro line ld a,line M_VDP 19 endm ; M_VBLANKON: turn ON vblank interrupts ; syntax: M_VBLANKON ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_VBLANKON macro ld a,(vdpregs0+1) or 000100000b ld (vdpregs0+1),a M_VDP 1 endm ; M_VBLANKOFF: turn OFF vblank interrupts ; syntax: M_VBLANKOFF ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_VBLANKOFF macro ld a,(vdpregs0+1) and 011011111b ld (vdpregs0+1),a M_VDP 1 endm ; M_LINEINTON: turn ON line interrupts ; syntax: M_LINEINTON ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_LINEINTON macro ld a,(vdpregs0+0) or 000010000b ld (vdpregs0+0),a M_VDP 0 endm ; M_LINEINTOFF: turn OFF line interrupts ; syntax: M_LINEINTOFF ; note: **** INTERRUPTS MUST BE DISABLED **** ; M_LINEINTOFF macro ld a,(vdpregs0+0) and 011101111b ld (vdpregs0+0),a M_VDP 0 endm ; ***************** ; **** Message **** ; ***************** ; jump to entry point ; jp start defb 13 defb 'rocks.as - overscan test in GRAPHIC 3 mode',10,13 defb 'Copyright (C) 2000 ag0ny@ag0ny.com',10 defb 26 ; ******************* ; **** Functions **** ; ******************* ; set GRAPHIC 3 mode ; modifies: A ; note: **** INTERRUPTS MUST BE DISABLED **** ; graphic3: ; set VDP mode GRAPHIC 3 ld a,(vdpregs0+0) and 011110001b or 000000100b ld (vdpregs0+0),a ; R#0 -> xxxx010xb M_VDP 0 ; write VDP R#0 ld a,(vdpregs0+1) and 011100111b ld (vdpregs0+1),a ; R#1 -> xxx00xxxb M_VDP 1 ; write VDP R#1 ret ; set VRAM address for read/write (low 64Kb) ; input: DE = VRAM address (bits A0-A15) ; modifies: A ; note: **** INTERRUPTS MUST BE DISABLED **** ; setvramaddr_w: ld a,d rlca rlca and 000000011b M_VDP 14 ; bits A16-A14 to VDP R#14 ld a,e out (vdpport1),a ; bits A7-A0 to VDP (low 16Kb) ld a,d and 000111111b or 001000000b out (vdpport1),a ; bits A13-A8 to VDP, bit 6 = 1 (W) ret ; interrupt code ; i200: M_VDPST 1 ld hl,i224 ld (00038h+1),hl M_192LN ld hl,VSCROLL ld a,224 add a,(hl) M_VDP 19 ei ret i224: M_VDPST 1 ld a,(VSCROLL) inc a ld (VSCROLL),a M_VDP 23 ld hl,i200 ld (00038h+1),hl M_212LN ld hl,VSCROLL ld a,200 add a,(hl) M_VDP 19 ei ret ; ***************************** ; **** Program starts here **** ; ***************************** start: di M_VBLANKOFF M_212LN M_SETINTLN 200 M_LINEINTON xor a ld (vdpregs0+7),a M_VDP 7 ; set border color = 0 call graphic3 ld hl,newint ; install our interrupt code ld de,00038h ld bc,3 ldir ld a,000000110b ; Pattern name table in 01800h M_VDP 2 ld a,010000000b or 01fh ; Color table in 02000h M_VDP 3 ld a,0 ; Pattern generator table at 00000h M_VDP 4 M_R2V8 pat000,TAB_GENERATOR,5*8 M_R2V8 col000,TAB_COLOR,5*8 ld bc,1024 ld hl,SCR_BUFFER buc: ld a,r and 000000011b inc a ld (hl),a inc hl dec bc ld a,b or c jr nz,buc M_R2V16 SCR_BUFFER,TAB_NAME,1024 M_R2V16 SCR_BUFFER,TAB_NAME,1024 ei loop: jr loop ; ************** ; **** Data **** ; ************** newint: jp i200 pat000: defb 000h,000h,000h,000h,000h,000h,000h,000h pat001: defb 03ch,07eh,05dh,009h,062h,018h,07ch,000h pat002: defb 002h,098h,03ch,03eh,01eh,05ch,060h,000h pat003: defb 018h,03ch,018h,006h,04fh,00fh,026h,020h pat004: defb 00ch,06ch,0f0h,0f3h,0f3h,060h,006h,004h col000: defb 000h,000h,000h,000h,000h,000h,000h,000h col001: defb 0f0h,0f4h,075h,075h,054h,054h,040h,000h col002: defb 070h,0f0h,070h,050h,050h,040h,040h,000h col003: defb 0f0h,070h,050h,0f0h,070h,050h,040h,050h col004: defb 070h,050h,070h,070h,050h,040h,040h,040h ADJUST: defb 0 VSCROLL: defb 0 SCR_BUFFER: defb 0  FFER: defb 0 fb 0 SCR_BUFFER: defb 0  col004: defb 070h,050h,070h,070h,050h,040h,040h,040h ADJUST: defb 0 VSCROLL: defb 0 SCR_BUFFER: defb 0 0 VSCROLL: defb 0 SCR_BUFFER: defb 0 UFFER: defb 0 050h col004: defb 070h,050h,070h,070h,050h,040h,040h,040h SCR_BUFFER: defb 0