%include "WonderSwan.inc" MYSEGMENT equ 0xF000 ; Set Maps and Sprite Table at the end of first part of ram fgmap equ WSC_TILE_BANK1-MAP_SIZE bgmap equ fgmap-MAP_SIZE sprtable equ bgmap-SPR_TABLE_SIZE CPU 186 BITS 16 ;PADDING 15 ; Pad 15 Sections SECTION TEXT ORG 0x0000 Start: cli ; Disable Interrupts cld ; Offset in Increment mode xor ax,ax ; Clear all registers mov bx,ax mov cx,ax mov dx,ax mov si,ax mov di,ax mov ds,ax ; Clear Segments mov es,ax mov bp,ax ; Setup stack mov ss,ax mov sp,WS_STACK in al,IO_HARDWARE_TYPE ; Check Wonderswan Mono/Color test al,WS_COLOR .mono: jz .mono ; We loop forever if Mono mov sp,WSC_STACK ; New stack xor ax,ax ; Clear Ram mov di,0x100 mov cx,0x7E80 rep stosw out IO_SRAM_BANK,al ; Video Init in al,IO_VIDEO_MODE or al,VMODE_16C_CHK | VMODE_CLEANINIT out IO_VIDEO_MODE,al xor ax,ax out IO_BG_X,al out IO_BG_Y,al out IO_FG_X,al out IO_FG_Y,al out IO_SPR_START,al out IO_SPR_STOP,al mov al,BG_MAP(bgmap) | FG_MAP(fgmap) out IO_FGBG_MAP,al mov al,SPR_TABLE(sprtable) out IO_SPR_TABLE,al in al,IO_LCD_CTRL or al,LCD_ON out IO_LCD_CTRL,al xor al,al out IO_LCD_ICONS,al ; Setup VBlank Int mov ax,INT_BASE out IO_INT_BASE,al mov di,INTVEC_VBLANK_START add di,ax shl di,2 ; *4 mov word [es:di],VBlank mov word [es:di+0x2],MYSEGMENT xor ax,ax ; Clear HBL & Timer out IOw_HBLANK_FREQ,ax out IO_TIMER_CTRL,al dec al ; Ack all Int out IO_INT_ACK,al mov al,INT_VBLANK_START ; Enable VBL Int out IO_INT_ENABLE,al sti ; Enable Interrupts ! ;-------------------------------- ; Set Segments for Copy mov ax,MYSEGMENT mov ds,ax xor ax,ax mov es,ax ; Make BG mov si,TileGfx mov di,WSC_TILE_BANK1 mov cx,(TileGfxE-TileGfx)/2 rep movsw mov si,TilePal mov di,WSC_PALETTES mov cx,16 rep movsw mov ax,BG_CHR(0,0,0,0,0) ; Initial Tile, Pal 0, Bank 0 mov di,bgmap mov cx,MAP_TWIDTH*MAP_THEIGHT rep stosw ; Display ! mov al,BG_ON | FG_ON out IO_DISPLAY_CTRL,al ; Loop Read Buttons loop: mov al,KEYPAD_READ_BUTTONS out IO_KEYPAD,al nop nop nop nop in al,IO_KEYPAD test al,PAD_A ; Press A for Audio jz loop jmp loop ;****************************************** VBlank: push ax mov al,[es:VBLcnt] inc al mov [es:VBLcnt],al and al,3 jnz .noscroll in al,IO_BG_X ; Infinite Scroll inc al out IO_BG_X,al in al,IO_BG_Y inc al out IO_BG_Y,al .noscroll: in al,IO_INT_ACK or al,INT_VBLANK_START out IO_INT_ACK,al pop ax iret ;****************************************** align 2 TilePal: incbin "gfx/bgtile.pal" TileGfx: incbin "gfx/bgtile.gfx" TileGfxE: ;****************************************** ROM_HEADER Start, MYSEGMENT, 0x42, RH_WS_COLOR, RH_ROM_8MBITS, RH_NO_SRAM, RH_HORIZONTAL ;****************************************** SECTION BSS start=0x0100 ; Keep space for Int Vectors VBLcnt: resb 0 ; Our datas in RAM