The project is sort of an updated c64 with a 65816 and 32mb ram (16mb code, 16mb data). The cpu is already written and works fine. Even has mult & div instructions, using the WDM opcode. So it's not exactly a 65816.
The program asks the user if they want a 16:9 or 4:3 screen. It correctly picks the proper resolution and defaults to 1024x768 (if the graphics card will do it-otherwise just exits) in order to handle a 800x600 screen with border. I transfer the 800x600 screen, along with 16 sprites to the backbuffer & flip 50x/sec. No problems. Originally I used 32-bit color but want to make it a little more authentic and use 256 colors. I understand I could still use a 256-color software palette using on the fly translation, or even 16-bit color, and that may be where this is headed if I can't work with the real palette.
The code below is just the relevant parts creating the primary surface, the palette, and attaching the palette.
(It's in GoAsm--msgbox error stuff removed)
; CREATE PRIMARY SURFACE
;PREPARE TO CREATE PRIMARY SURFACE
;CLEAR SURFACE DESCRIPTION STRUCTURE
x3:
mov ecx, SIZEOF structSURFDESCPri ;index
mov eax, ADDR structSURFDESCPri ;DEST
mov dl, 0 ;POKE value
x3.1:
mov [eax], dl ;POKE (DEST)
inc eax ;inc DEST
dec ecx ;dec index
jnz <x3.1 ;until index = 0
;FILL VALID PARAMS
;CREATE A PRIMARY SURFACE WITH A BACK BUFFER
mov D[structSURFDESCPri.dwSize], SIZEOF structSURFDESCPri
mov D[structSURFDESCPri.dwFlags], DDSD_CAPS | DDSD_BACKBUFFERCOUNT
mov D[structSURFDESCPri.ddsCaps.dwCaps], \
DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX ;| DDSCAPS_PALETTE (doesn't work)
mov D[structSURFDESCPri.dwBackBufferCount], 1
CoInvoke(ptrIDirectDraw, IDirectDraw7.CreateSurface, \
ADDR structSURFDESCPri, ADDR ptrISurfacePri, NULL)
cmp eax, DD_OK
je >x4 ;surface created successfully
;could not create, so display error message and quit
;CREATE THE PALETTE
x4:
CoInvoke(ptrIDirectDraw, IDirectDraw7.CreatePalette, \
DDPCAPS_8BIT | DDPCAPS_ALLOW256, \
ADDR ecPALETTE, ADDR ptrIPalette, NULL)
cmp eax, DD_OK
je >x4.1
;ATTACH THE PALETTE TO THE PRIMARY SURFACE
x4.1:
CoInvoke(ptrISurfacePri, IDirectDrawSurface7.SetPalette, [ptrIPalette])
cmp eax, DD_OK
je >>x5
This all works and I get the right thing up on the screen--except for the color, which is always the same, regardless of what is in the palette table. I'm wondering if I have the right flags set in these particular calls.