+++ /dev/null
-
-%include "WonderSwan.inc"
-
-extern _main
-extern _test_copy
-extern __etext
-extern __seg1DL
-extern __seg1DH
-extern __edata
-extern __end
-
-MYSEGMENT equ 0xF000
-USER_RAM equ 0x1000
-
-; 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
-
- ;call _main
-
- xor ax,ax ; Clear Ram
- mov di,0x100
- mov cx,0x7E80
- rep stosw
-
- out IO_SRAM_BANK,al
-
-
- ;mov cx, 0x100
-
- ; 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,0x2000 ; ! note, try 0x2000, 0x4000, etc..
- mov ds,ax
- xor ax,ax
- mov es,ax
-
- mov si, __seg1DL
- mov di, USER_RAM
- mov ax, __seg1DH
- mov bx, __seg1DL
- sub bx, ax
- mov cx, ax
- rep movsb
- ; 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,32
- ;rep movsb
-;back:
- call _main
- ;call _main
- ;call _test_copy
- ;call _test_copy
- ;jmp back
-
- 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
-
-blaat:
- jmp blaat
-
- ; 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
-
- call _main
- 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 __end, 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
-
-/* #include <code16bit.h> */
-#include <memory.h>
-void outport(c)
- unsigned c;
-{
-#asm
- xor dx, dx
- mov dx, ax
- shr dx, 8
- out dx, al
- ;out 0x15, al
-#endasm
-}
-
-static unsigned char data[] = {
-0x65, 0x06, 0x67, 0x06, 0x79, 0x07, 0x8c, 0x08, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f,
-0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f
+/* sprite data */
+unsigned char bgtile_gfx[] = {
+ 0x31, 0x22, 0x31, 0x32, 0x22, 0x31, 0x23, 0x21, 0x13, 0x13, 0x31, 0x32,
+ 0x32, 0x31, 0x23, 0x12, 0x21, 0x32, 0x13, 0x23, 0x23, 0x13, 0x31, 0x31,
+ 0x12, 0x32, 0x13, 0x22, 0x23, 0x13, 0x22, 0x13
};
-static unsigned char data2[] = {
-0x65, 0x06, 0x67, 0x06, 0x79, 0x07, 0x8c, 0x08, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f,
-0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f
+/* palette data */
+unsigned char bgtile_pal[] = {
+ 0x65, 0x06, 0x67, 0x06, 0x79, 0x07, 0x8c, 0x08, 0xff, 0x0f, 0xff, 0x0f,
+ 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f,
+ 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f
};
-static unsigned char data3[] = {
-0x65, 0x06, 0x67, 0x06, 0x79, 0x07, 0x8c, 0x08, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f,
-0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f
-};
-
+/* data */
+unsigned char lol[5] = { 0xAA, 0x2, 0x3, 0x4, 0x5};
+unsigned char lol2[5] = { 0x1, 0x2, 0x3, 0x4, 0x5};
+unsigned char lol3[5] = { 0x1, 0x2, 0x3, 0x4, 0x5};
+#define PALETTE (*(volatile unsigned *)0xFE00)
+#define PALETTE_T (volatile unsigned *)0xFE00
+#define SPRITE_T (volatile unsigned *)0x4000
-unsigned short *memcpy(dest, src, cnt)
- unsigned short *dest;
- unsigned short *src;
- int cnt;
-{
-
- int i;
-#asm
- ;push ds
- ;push es
- mov ax, 0x0
- mov ds, ax
- xor ax, ax
- mov es, ax
-#endasm
- for (i = 0; i < cnt; ++i) {
- *dest++ = *src++;
- //*dest++ = 0x66;
- }
-#asm
- ;pop es
- ;pop ds
- mov ds, 0xF000
-#endasm
- return dest;
-}
-
-void test_copy()
-{
-#asm
- ;mov ds, 0
-#endasm
-
-// unsigned short dest = 0xFE00;
-// unsigned * ptr = dest;
-// *ptr++ = 0xDEAD;
-// *ptr++ = 0xAAAA;
-// *ptr++ = 0xDEAD;
- memcpy(0xFE00, 0x1000, 16);
-#asm
- ;mov ds, 0xF000
-#endasm
- //wmemcpy(WSC_PALETTES, 0x2F000, 32);
- return;
-}
+/* bss */
+static unsigned char blaat[100];
-int main()
+int main(void)
{
- unsigned short data_seg = 0xF000;
- unsigned short data_ram = 0x1000;
- unsigned short rel_ram = data_seg - data_ram;
+ lol[0] = 0xDD;
+ lol[1] = 0xDD;
- /* dummy */
- memcpy(0x0, 0x0, 0);
-
- memcpy(0xFE00, data - rel_ram, 16);
- //memcpy(0xFE00, data_seg + data, 16);
+ blaat[0] = 0xEE;
+ blaat[1] = 0xEE;
+ blaat[32] = 0xEE;
- //while(1) {
- // /* outport(0x15EE); */
- // unsigned reg = 0x15;
- // unsigned val = 0xEE;
- // outport((reg << 8) | val);
-
- //}
+ unsigned char * ptr = PALETTE_T;
+ for (int i = 0; i < sizeof(bgtile_pal); ++i) {
+ *ptr++ = bgtile_pal[i];
+ }
+
+ ptr = SPRITE_T;
+ for (int i = 0; i < sizeof(bgtile_gfx); ++i) {
+ *ptr++ = bgtile_gfx[i];
+ }
+ while(1) {
+ }
return 0;
}