doomhack / GBADoom

A port of prBoom to the Nintendo GBA.
182 stars 25 forks source link

Not so much an issue more of a question: Is it possible to change the scale of an image drawn with V_DrawPatch? #20

Closed Rorybabory closed 2 years ago

Rorybabory commented 2 years ago

I'm working on porting doom to a very weak device using this port as a base, but for storage reasons I need to downscale the titlescreen and other UI elements. I changed the resolution in the IWAD, however it then just shows up as very small in the top left corner. Now I am trying to understand how to scale it back up.

doomhack commented 2 years ago

Hi,

The V_DrawPatch function is hard-coded to draw images (patch_t) at the GBA's 240x160 resolution.

You should be able to change this by modifying lines 97-101 in V_Video.c. This is where it computes the scaling steps.

const int   DX  = (240<<16) / 320;
const int   DXI = (320<<16) / 240;
const int   DY  = ((SCREENHEIGHT<<16)+(FRACUNIT-1)) / 200;
const int   DYI = (200<<16) / SCREENHEIGHT;

Swap the 320 for the width of your images and the 200 for the height.

This function is used to draw a few things like the status bar too so you might want to create a copy of the function and call it to draw the images you scaled else you'll have to scale all of the other UI patches too.

This function is also going to be quite slow due to the branch and read-combine-write in the inner loop. This is because on the GBA, you can only write to video memory in 16 or 32bit words. (8bit writes are weird!)