diff --git a/gr-sim/hellmood_memories/hellmood_gr.c b/gr-sim/hellmood_memories/hellmood_gr.c index 60786eec..27594014 100644 --- a/gr-sim/hellmood_memories/hellmood_gr.c +++ b/gr-sim/hellmood_memories/hellmood_gr.c @@ -31,186 +31,6 @@ static unsigned short stack[128]; static unsigned short ax,bx,cx,dx,es; static int cf=0,of=0,zf=0,sf=0; static int sp=0; -static unsigned char framebuffer[320*200]; - -static SDL_Surface *sdl_screen=NULL; - -struct palette { - unsigned char red[256]; - unsigned char green[256]; - unsigned char blue[256]; -}; - -static struct palette pal; - -static int mode13h_graphics_init(void) { - - int mode; - - mode=SDL_SWSURFACE|SDL_HWPALETTE|SDL_HWSURFACE; - - if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { - fprintf(stderr, - "Couldn't initialize SDL: %s\n", SDL_GetError()); - return -1; - } - - /* Clean up on exit */ - atexit(SDL_Quit); - - /* assume 32-bit color */ - sdl_screen = SDL_SetVideoMode(320, 200, 32, mode); - - if ( sdl_screen == NULL ) { - fprintf(stderr, "ERROR! Couldn't set 320x200 video mode: %s\n", - SDL_GetError()); - return -1; - } - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); - - SDL_WM_SetCaption("memories -- Linux/C/SDL","memories"); - - return 0; -} - -static int mode13h_graphics_update(unsigned char *buffer, struct palette *pal) { - - unsigned int *t_pointer; - - int x,temp; - - /* point to SDL output pixels */ - t_pointer=((Uint32 *)sdl_screen->pixels); - - for(x=0;x<320*200;x++) { - - temp=(pal->red[buffer[x]]<<16)| - (pal->green[buffer[x]]<<8)| - (pal->blue[buffer[x]]<<0)|0; - - t_pointer[x]=temp; - } - - SDL_UpdateRect(sdl_screen, 0, 0, 320, 200); - - return 0; -} - -static void set_vga_pal(void) { - -/* output of vgapal https://github.com/canidlogic/vgapal */ -unsigned char raw_pal[3*256]= -{ 0, 0, 0, 0, 0, 170, 0, 170, 0, 0, 170, 170, -170, 0, 0, 170, 0, 170, 170, 85, 0, 170, 170, 170, - 85, 85, 85, 85, 85, 255, 85, 255, 85, 85, 255, 255, -255, 85, 85, 255, 85, 255, 255, 255, 85, 255, 255, 255, - 0, 0, 0, 20, 20, 20, 32, 32, 32, 44, 44, 44, - 56, 56, 56, 69, 69, 69, 81, 81, 81, 97, 97, 97, -113, 113, 113, 130, 130, 130, 146, 146, 146, 162, 162, 162, -182, 182, 182, 203, 203, 203, 227, 227, 227, 255, 255, 255, - 0, 0, 255, 65, 0, 255, 125, 0, 255, 190, 0, 255, -255, 0, 255, 255, 0, 190, 255, 0, 125, 255, 0, 65, -255, 0, 0, 255, 65, 0, 255, 125, 0, 255, 190, 0, -255, 255, 0, 190, 255, 0, 125, 255, 0, 65, 255, 0, - 0, 255, 0, 0, 255, 65, 0, 255, 125, 0, 255, 190, - 0, 255, 255, 0, 190, 255, 0, 125, 255, 0, 65, 255, -125, 125, 255, 158, 125, 255, 190, 125, 255, 223, 125, 255, -255, 125, 255, 255, 125, 223, 255, 125, 190, 255, 125, 158, -255, 125, 125, 255, 158, 125, 255, 190, 125, 255, 223, 125, -255, 255, 125, 223, 255, 125, 190, 255, 125, 158, 255, 125, -125, 255, 125, 125, 255, 158, 125, 255, 190, 125, 255, 223, -125, 255, 255, 125, 223, 255, 125, 190, 255, 125, 158, 255, -182, 182, 255, 199, 182, 255, 219, 182, 255, 235, 182, 255, -255, 182, 255, 255, 182, 235, 255, 182, 219, 255, 182, 199, -255, 182, 182, 255, 199, 182, 255, 219, 182, 255, 235, 182, -255, 255, 182, 235, 255, 182, 219, 255, 182, 199, 255, 182, -182, 255, 182, 182, 255, 199, 182, 255, 219, 182, 255, 235, -182, 255, 255, 182, 235, 255, 182, 219, 255, 182, 199, 255, - 0, 0, 113, 28, 0, 113, 56, 0, 113, 85, 0, 113, -113, 0, 113, 113, 0, 85, 113, 0, 56, 113, 0, 28, -113, 0, 0, 113, 28, 0, 113, 56, 0, 113, 85, 0, -113, 113, 0, 85, 113, 0, 56, 113, 0, 28, 113, 0, - 0, 113, 0, 0, 113, 28, 0, 113, 56, 0, 113, 85, - 0, 113, 113, 0, 85, 113, 0, 56, 113, 0, 28, 113, - 56, 56, 113, 69, 56, 113, 85, 56, 113, 97, 56, 113, -113, 56, 113, 113, 56, 97, 113, 56, 85, 113, 56, 69, -113, 56, 56, 113, 69, 56, 113, 85, 56, 113, 97, 56, -113, 113, 56, 97, 113, 56, 85, 113, 56, 69, 113, 56, - 56, 113, 56, 56, 113, 69, 56, 113, 85, 56, 113, 97, - 56, 113, 113, 56, 97, 113, 56, 85, 113, 56, 69, 113, - 81, 81, 113, 89, 81, 113, 97, 81, 113, 105, 81, 113, -113, 81, 113, 113, 81, 105, 113, 81, 97, 113, 81, 89, -113, 81, 81, 113, 89, 81, 113, 97, 81, 113, 105, 81, -113, 113, 81, 105, 113, 81, 97, 113, 81, 89, 113, 81, - 81, 113, 81, 81, 113, 89, 81, 113, 97, 81, 113, 105, - 81, 113, 113, 81, 105, 113, 81, 97, 113, 81, 89, 113, - 0, 0, 65, 16, 0, 65, 32, 0, 65, 48, 0, 65, - 65, 0, 65, 65, 0, 48, 65, 0, 32, 65, 0, 16, - 65, 0, 0, 65, 16, 0, 65, 32, 0, 65, 48, 0, - 65, 65, 0, 48, 65, 0, 32, 65, 0, 16, 65, 0, - 0, 65, 0, 0, 65, 16, 0, 65, 32, 0, 65, 48, - 0, 65, 65, 0, 48, 65, 0, 32, 65, 0, 16, 65, - 32, 32, 65, 40, 32, 65, 48, 32, 65, 56, 32, 65, - 65, 32, 65, 65, 32, 56, 65, 32, 48, 65, 32, 40, - 65, 32, 32, 65, 40, 32, 65, 48, 32, 65, 56, 32, - 65, 65, 32, 56, 65, 32, 48, 65, 32, 40, 65, 32, - 32, 65, 32, 32, 65, 40, 32, 65, 48, 32, 65, 56, - 32, 65, 65, 32, 56, 65, 32, 48, 65, 32, 40, 65, - 44, 44, 65, 48, 44, 65, 52, 44, 65, 60, 44, 65, - 65, 44, 65, 65, 44, 60, 65, 44, 52, 65, 44, 48, - 65, 44, 44, 65, 48, 44, 65, 52, 44, 65, 60, 44, - 65, 65, 44, 60, 65, 44, 52, 65, 44, 48, 65, 44, - 44, 65, 44, 44, 65, 48, 44, 65, 52, 44, 65, 60, - 44, 65, 65, 44, 60, 65, 44, 52, 65, 44, 48, 65, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - - int i; - - for(i=0;i<256;i++) { - pal.red[i]=raw_pal[i*3]; - pal.green[i]=raw_pal[(i*3)+1]; - pal.blue[i]=raw_pal[(i*3)+2]; - - } - return; - -} - -static int graphics_input(void) { - - SDL_Event event; - int keypressed; - - while ( SDL_PollEvent(&event)) { - - switch(event.type) { - - case SDL_KEYDOWN: - keypressed=event.key.keysym.sym; - switch (keypressed) { - - case SDLK_ESCAPE: - return 27; - } - break; - } - } - return 0; - -} - - -static void write_framebuffer(int address, int value) { - int real_addr; - - real_addr=address-0xa0000; - if ((real_addr<0) || (real_addr>320*200)) return; - - framebuffer[real_addr]=value; - -} /* unsigned multiply */ static void mul_16(unsigned short value) { @@ -474,9 +294,7 @@ static int fx1(int xx, int yy, int xprime) { /* checkers */ static int fx2(int xx, int yy, int xprime) { - return 0; -} -#if 0 + int color; color=((yy&0xff)<<8) | (xprime&0xff); @@ -488,7 +306,7 @@ static int fx2(int xx, int yy, int xprime) { return color; } -#endif + /* parallax checkerboard */ static int fx3(int xx,int yy,int xprime) { @@ -729,8 +547,8 @@ int main(int argc, char **argv) { which=frame/512; switch (which&0xff) { - case 1: color=fx2(xx,yy,xprime); break; - case 0: color=fx1(xx,yy,xprime); break; + case 0: color=fx2(xx,yy,xprime); break; + case 1: color=fx1(xx,yy,xprime); break; case 2: color=fx0(xx,yy,xprime); break; case 3: color=fx3(xx,yy,xprime); break; case 4: color=fx4(xx,yy,xprime); break; diff --git a/gr-sim/hellmood_memories/hellmood_simple.c b/gr-sim/hellmood_memories/hellmood_simple.c index 7031dd65..68ed494e 100644 --- a/gr-sim/hellmood_memories/hellmood_simple.c +++ b/gr-sim/hellmood_memories/hellmood_simple.c @@ -409,10 +409,10 @@ static int fx0(int xx, int yy, int xprime) { char ah,al,dh,dl; unsigned short temp; + int color; ax=0x1329; // mov ax,0x1329 init - - al=ax&0xff; ah=(ax>>8)&0xff; + al=0x29; ah=0x13; dl=xprime; dh=yy; @@ -433,11 +433,11 @@ static int fx0(int xx, int yy, int xprime) { ah=(ax>>8)&0xff; ah=ah^dl; // xor ah,dl al=ah; // mov al,ah - ax=((ah&0xff)<<8)|(al&0xff); + color=((ah&0xff)<<8)|(al&0xff); - ax&=0xff1c; // and al,4+8+16 + color&=0x1c; // and al,4+8+16 - return ax; + return color; } /* circles? */ diff --git a/hellmood_memories/Makefile b/hellmood_memories/Makefile index eb2e47fe..ad3b36f1 100644 --- a/hellmood_memories/Makefile +++ b/hellmood_memories/Makefile @@ -8,11 +8,12 @@ B2D = ../bmp2dhr/b2d all: memories.dsk -memories.dsk: HELLO CIRCLES.BAS CIRCLES +memories.dsk: HELLO CIRCLES.BAS CIRCLES CHECKERS cp empty.dsk memories.dsk $(DOS33) -y memories.dsk SAVE A HELLO $(DOS33) -y memories.dsk SAVE A CIRCLES.BAS $(DOS33) -y memories.dsk BSAVE -a 0x070 CIRCLES + $(DOS33) -y memories.dsk BSAVE -a 0x070 CHECKERS CIRCLES: circles.o @@ -23,6 +24,15 @@ circles.o: circles.s ### +CHECKERS: checkers.o + ld65 -o CHECKERS checkers.o -C ../linker_scripts/apple2_70_zp.inc + +checkers.o: checkers.s + ca65 -o checkers.o checkers.s -l checkers.lst + +### + + HELLO: hello.bas ../asoft_basic-utils/tokenize_asoft < hello.bas > HELLO @@ -33,5 +43,5 @@ CIRCLES.BAS: zooming_circles.bas clean: - rm -f *~ *.o *.lst HELLO CIRCLES.BAS + rm -f *~ *.o *.lst HELLO CIRCLES.BAS CIRCLES CHECKERS diff --git a/hellmood_memories/checkers.monitor b/hellmood_memories/checkers.monitor new file mode 100644 index 00000000..6da82705 --- /dev/null +++ b/hellmood_memories/checkers.monitor @@ -0,0 +1,4 @@ +CALL -151 +70: 20 40 FB 2C 52 C0 E6 FC A2 2F A0 27 38 98 E5 FC 85 F1 8A E9 00 45 F1 09 DB 69 01 20 64 F8 8A 20 00 F8 88 10 E7 CA 10 E2 30 DC +70G + diff --git a/hellmood_memories/checkers.s b/hellmood_memories/checkers.s new file mode 100644 index 00000000..31769787 --- /dev/null +++ b/hellmood_memories/checkers.s @@ -0,0 +1,87 @@ +; Checkers, based on the code in Hellmood's Memories + +; 42 bytes +; could be shorter if you're not picky about colors + +; by deater (Vince Weaver) + +; Zero Page +BASL = $28 +BASH = $29 +H2 = $2C +COLOR = $30 + +X1 = $F0 +X2 = $F1 +Y1 = $F2 +Y2 = $F3 + +TEMP = $FA +TEMPY = $FB +FRAME = $FC +TEMPX = $FD + + +; Soft Switches +KEYPRESS= $C000 +KEYRESET= $C010 +SET_GR = $C050 ; Enable graphics +FULLGR = $C052 ; Full screen, no text +PAGE0 = $C054 ; Page0 +PAGE1 = $C055 ; Page1 +LORES = $C056 ; Enable LORES graphics + +; ROM routines + +PLOT = $F800 ; plot, horiz=y, vert=A (A trashed, XY Saved) +SETCOL = $F864 +TEXT = $FB36 ;; Set text mode +BASCALC = $FBC1 +SETGR = $FB40 +HOME = $FC58 ;; Clear the text screen +WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us +HLINE = $F819 + + +.zeropage + +checkers: + + ;=================== + ; init screen + jsr SETGR ; 3 + bit FULLGR ; 3 + ;==== + ; 6 +checkers_forever: + + inc FRAME ; 2 + + ldx #47 ; 2 +yloop: + ldy #39 ; 2 +xloop: + sec + tya + sbc FRAME + sta X2 + txa + sbc #0 + + eor X2 + ora #$DB + adc #1 + + jsr SETCOL + + txa ; A==Y1 ; 1 + jsr PLOT ; (X2,Y1) ; 3 + + dey ; 1 + bpl xloop ; 2 + + dex ; 1 + bpl yloop ; 2 + + bmi checkers_forever ; 2 + diff --git a/hellmood_memories/zooming_circles.bas b/hellmood_memories/zooming_circles.bas index 73d5ddcf..d45f1917 100644 --- a/hellmood_memories/zooming_circles.bas +++ b/hellmood_memories/zooming_circles.bas @@ -1,3 +1,5 @@ +' NOTE: SPEEDUPS: Use the 4-way symmetry +' ALSO: use data statement and lookup table? 1 GR:X=PEEK(49234):A(0)=0:A(1)=5:A(2)=0:A(3)=7 2 FOR Y=-24 TO 23: FOR X=-20 TO 19: Z=X*4/3:C=F+(Z*Z+Y*Y)/16: C=C-INT(C/32)*32:COLOR=A(C/8):PLOT X+20,Y+24:NEXT:NEXT:F=F+1: GOTO 2