Skip to content

Commit

Permalink
better monochrome scalers, doom/wolf3d cheats
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyakurdyukov authored Oct 21, 2024
1 parent db05376 commit a26fd58
Show file tree
Hide file tree
Showing 13 changed files with 255 additions and 135 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ All feature phone LCDs I've seen are vertical, if you have a phone with a horizo
| Power + RSoft | zoom out |
| Power + Dial | map |
| Power + 0 | gamma (0..4) |
| Power + 1,2,3 | I, D, Q |
| Power + 4,5,6 | K, F, A |

* D-pad and keys 1-9 are rotated with the `--rotate` option (with screen or separately).
* For phones without D-pad Center key (Nobby 170B) - up/down keys are used for fire.
Expand Down
46 changes: 22 additions & 24 deletions doom.patch
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ index 8954140..d814a9f 100644


diff --git a/i_video.c b/i_video.c
index 9b311b3..c1aa73d 100644
index 9b311b3..6900dc7 100644
--- a/i_video.c
+++ b/i_video.c
@@ -25,6 +25,7 @@ static const char
Expand Down Expand Up @@ -987,7 +987,7 @@ index 9b311b3..c1aa73d 100644

// Blocky mode,
// replace each 320x200 pixel with multiply*multiply pixels.
@@ -89,6 +101,96 @@ int doPointerWarp = POINTER_WARP_COUNTDOWN;
@@ -89,6 +101,94 @@ int doPointerWarp = POINTER_WARP_COUNTDOWN;
// to use ....
static int multiply=1;

Expand Down Expand Up @@ -1017,18 +1017,16 @@ index 9b311b3..c1aa73d 100644
+ /* wp_supershotgun */ wp_chaingun
+ } };
+ do {
+ ammotype_t ammo;
+ next = cycle[dir][next];
+ if (p->weaponowned[next]) {
+#if 0
+ if (1) {
+#else
+ ammotype_t ammo = weaponinfo[next].ammo;
+ if (ammo == am_noammo || p->ammo[ammo] > 0) {
+#endif
+ // p->pendingweapon = next;
+ return "123456713"[next];
+ }
+ }
+ if (!p->weaponowned[next]) continue;
+ ammo = weaponinfo[next].ammo;
+ if (ammo != am_noammo && p->ammo[ammo] <= 0) continue;
+ /* Only possible with cheats. */
+ if (next == wp_supershotgun && gamemode != commercial) continue;
+ if (ammo == am_cell && gamemode == shareware) continue;
+ // p->pendingweapon = next;
+ return "123456713"[next];
+ } while (next != cur);
+ return 0x8000;
+}
Expand Down Expand Up @@ -1084,7 +1082,7 @@ index 9b311b3..c1aa73d 100644

//
// Translates the key currently in X_event
@@ -272,7 +374,7 @@ void I_GetEvent(void)
@@ -272,7 +372,7 @@ void I_GetEvent(void)
break;

default:
Expand All @@ -1093,15 +1091,15 @@ index 9b311b3..c1aa73d 100644
break;
}

@@ -336,6 +438,7 @@ void I_StartTic (void)
@@ -336,6 +436,7 @@ void I_StartTic (void)
mousemoved = false;

}
+#endif


//
@@ -373,6 +476,11 @@ void I_FinishUpdate (void)
@@ -373,6 +474,11 @@ void I_FinishUpdate (void)

}

Expand All @@ -1113,15 +1111,15 @@ index 9b311b3..c1aa73d 100644
// scales the screen size before blitting it
if (multiply == 2)
{
@@ -518,6 +626,7 @@ void I_FinishUpdate (void)
@@ -518,6 +624,7 @@ void I_FinishUpdate (void)

}

+#endif
}


@@ -533,6 +642,12 @@ void I_ReadScreen (byte* scr)
@@ -533,6 +640,12 @@ void I_ReadScreen (byte* scr)
//
// Palette stuff.
//
Expand All @@ -1134,31 +1132,31 @@ index 9b311b3..c1aa73d 100644
static XColor colors[256];

void UploadNewPalette(Colormap cmap, byte *palette)
@@ -688,6 +803,7 @@ void grabsharedmemory(int size)
@@ -688,6 +801,7 @@ void grabsharedmemory(int size)
fprintf(stderr, "shared memory id=%d, addr=0x%x\n", id,
(int) (image->data));
}
+#endif

void I_InitGraphics(void)
{
@@ -699,6 +815,7 @@ void I_InitGraphics(void)
@@ -699,6 +813,7 @@ void I_InitGraphics(void)
int x=0;
int y=0;

+#ifndef EMBEDDED
// warning: char format, different type arg
char xsign=' ';
char ysign=' ';
@@ -708,6 +825,7 @@ void I_InitGraphics(void)
@@ -708,6 +823,7 @@ void I_InitGraphics(void)
XSetWindowAttributes attribs;
XGCValues xgcvalues;
int valuemask;
+#endif
static int firsttime=1;

if (!firsttime)
@@ -716,6 +834,11 @@ void I_InitGraphics(void)
@@ -716,6 +832,11 @@ void I_InitGraphics(void)

signal(SIGINT, (void (*)(int)) I_Quit);

Expand All @@ -1170,7 +1168,7 @@ index 9b311b3..c1aa73d 100644
if (M_CheckParm("-2"))
multiply = 2;

@@ -912,9 +1035,11 @@ void I_InitGraphics(void)
@@ -912,9 +1033,11 @@ void I_InitGraphics(void)
else
screens[0] = (unsigned char *) malloc (SCREENWIDTH * SCREENHEIGHT);

Expand All @@ -1182,7 +1180,7 @@ index 9b311b3..c1aa73d 100644
unsigned exptable[256];

void InitExpand (void)
@@ -1046,5 +1171,6 @@ Expand4
@@ -1046,5 +1169,6 @@ Expand4
xline += step;
} while (y--);
}
Expand Down
8 changes: 8 additions & 0 deletions fpbuild/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ Port of games on the Build Engine. Using [jfbuild](https://github.com/jonof/jfbu
| * | crouch |
| 0 | next item |
| 8 | use item |
| Power + Center | use |
| Power + Up | run on/off |
| Power + Down | open/close menu |
| Power + L/R | prev/next weapon |
| Power + LSoft | zoom in |
| Power + RSoft | zoom out |
| Power + Dial | map |
| Power + 0 | gamma (0..7) |

### Issues

Expand Down
100 changes: 72 additions & 28 deletions fpbuild/fp_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main(int argc, char **argv) {
uint32_t cachesize = maxcache1dsize;
cachesize += ram_size - (4 << 20);
// 160x128 mode uses less memory for the framebuffer
if (sys_data.display.h2 == 128) cachesize += 105 << 10;
if (sys_data.display.h2 <= 128) cachesize += 105 << 10;
if (cachesize > 4 << 20) cachesize = 4 << 20;
maxcache1dsize = cachesize;
}
Expand Down Expand Up @@ -147,6 +147,7 @@ enum {
X(0x34, DOT)
X(0x39, SPACE)
X(0x3a, CAPSLOCK)
X(0x57, F11)
X(0xc8, UP)
X(0xcb, LEFT)
X(0xcd, RIGHT)
Expand Down Expand Up @@ -197,6 +198,7 @@ void keytrn_init(void) {
KEY(LSOFT, KEY_EQUALS)
KEY(RSOFT, KEY_MINUS)
KEY(DIAL, KEY_TAB) /* map */
KEY(0, KEY_F11) /* gamma */
#undef KEY
};
int i, flags = sys_getkeymap(keymap);
Expand Down Expand Up @@ -343,6 +345,11 @@ int setvideomode(int x, int y, int c, int fs) {

getvalidmodes();
x = disp->w2; y = disp->h2;
if (y <= 68) {
x = 320;
if (y == 68) y = 226;
else y = 224;
}
if (sys_data.scaler == 1) x <<= 1, y <<= 1;
buildprintf("Setting video mode %dx%d\n", x, y);

Expand Down Expand Up @@ -482,37 +489,72 @@ DEF(void, scr_update_1d2, (uint8_t *s, void *dest)) {

/* display aspect ratio 7:5, LCD pixel aspect ratio 7:10 */
DEF(void, scr_update_128x64, (uint8_t *s, void *dest)) {
uint8_t *d = (uint8_t*)dest;
uint8_t *c8 = (uint8_t*)dest - 256;
unsigned x, y, h = 224;
uint8_t *d = (uint8_t*)dest, *c8 = dest - 256;
unsigned x, y, h = 64;
uint32_t a, b, t;
// 00112 23344
#define X(op) \
a op (c8[s2[0]] + c8[s2[1]]) * 2; \
a += t = c8[s2[2]]; \
b op t + (c8[s2[3]] + c8[s2[4]]) * 2;
#define X \
t = c8[s2[2]]; t += t << 16; \
t += (c8[s2[0]] + c8[s2[1]]) << 1; \
t += (c8[s2[3]] + c8[s2[4]]) << 17; \
s2 += 320; a += t << 1;
do {
for (x = 0; x < 320; x += 5, s += 5) {
uint8_t *s2 = s;
X(=) s2 += 320; X(+=) s2 += 320; X(+=)
a = (a + 7) * 0x8889 >> 19; // div15
b = (b + 7) * 0x8889 >> 19;
const uint8_t *s2 = s;
for (a = 0, y = 0; y < 4; y++) { X }
a -= t;
b = a >> 16; a &= 0xffff;
a = (a + 35 / 2) * 0xea0f >> 21; // div35
b = (b + 35 / 2) * 0xea0f >> 21;
*d++ = (a + 1) >> 1;
*d++ = (b + 1) >> 1;
for (a = t, y = 0; y < 3; y++) { X }
b = a >> 16; a &= 0xffff;
a = (a + 35 / 2) * 0xea0f >> 21; // div35
b = (b + 35 / 2) * 0xea0f >> 21;
d[126] = (a + 1) >> 1;
d[127] = (b + 1) >> 1;
}
s += 320 * 2;
for (x = 0; x < 320; x += 5, s += 5) {
uint8_t *s2 = s;
X(=) s2 += 320; X(+=) s2 += 320; X(+=) s2 += 320; X(+=)
a = a * 0xcccd + 0x7c000; // div20
b = b * 0xcccd + 0x7c000;
a = (a + (a >> 6 & 0x4000)) >> 20;
b = (b + (b >> 6 & 0x4000)) >> 20;
s += 320 * 6; d += 128;
} while ((h -= 2));
#undef X
}

DEF(void, scr_update_96x68, (uint8_t *s, void *dest)) {
uint8_t *d = (uint8_t*)dest;
uint8_t *c8 = (uint8_t*)dest - 256;
unsigned x, y = 0, h = 68; // (3+3+4)*22+3+3
uint32_t a, b, c, t0, t1;
// 0001112223 3344455566 6777888999
#define X(op) \
a op (c8[s2[0]] + c8[s2[1]] + c8[s2[2]]) * 3; \
a += t0 = c8[s2[3]]; \
b op t0 * 2 + (c8[s2[4]] + c8[s2[5]]) * 3; \
b += (t1 = c8[s2[6]]) * 2; \
c op t1 + (c8[s2[7]] + c8[s2[8]] + c8[s2[9]]) * 3;
// (3+3+4)*22+3+3
do {
for (x = 0; x < 320; x += 10, s += 10) {
uint8_t *s2 = s; uint32_t m;
X(=) s2 += 320; X(+=) s2 += 320; X(+=)
m = 0x8889 * 2; // div30
if (y == 2) {
s2 += 320; X(+=)
m = 0xcccd; // div40
}
a = a * m + 0xfc000;
b = b * m + 0xfc000;
c = c * m + 0xfc000;
a = (a + (a >> 7 & 0x4000)) >> 21;
b = (b + (b >> 7 & 0x4000)) >> 21;
c = (c + (c >> 7 & 0x4000)) >> 21;
*d++ = (a + 1) >> 1;
*d++ = (b + 1) >> 1;
*d++ = (c + 1) >> 1;
}
s += 320 * 3;
} while ((h -= 7));
s += 320 * 2;
if (++y == 3) s += 320, y = 0;
} while ((h -= 1));
#undef X
}

Expand All @@ -526,14 +568,15 @@ extern int scr_update_data[2];
#endif

uint8_t *framebuffer_init(void) {
static const uint8_t pal_size[] = { 2, 4, 1 };
static const uint8_t pal_size[] = { 2, 4, 1, 1 };
static const struct {
void (*pal_update)(uint8_t *pal, void *dest, const uint8_t *gamma);
void (*scr_update)(uint8_t *src, void *dest);
} fn[] = {
{ pal_update16, scr_update_1d1 },
{ pal_update32, scr_update_1d2 },
{ pal_update8, scr_update_128x64 },
{ pal_update8, scr_update_96x68 },
};
struct sys_display *disp = &sys_data.display;
int w = disp->w2, h = disp->h2;
Expand All @@ -546,8 +589,9 @@ uint8_t *framebuffer_init(void) {
dest += size2;

#ifdef USE_ASM
scr_update_data[0] = w << mode;
scr_update_data[1] = h << mode;
if (mode == 1) w <<= 1, h <<= 1;
scr_update_data[0] = w;
scr_update_data[1] = h;
#endif
app_pal_update = fn[mode].pal_update;
app_scr_update = fn[mode].scr_update;
Expand All @@ -557,9 +601,9 @@ uint8_t *framebuffer_init(void) {
void lcd_appinit(void) {
struct sys_display *disp = &sys_data.display;
unsigned w = disp->w1, h = disp->h1, mode;
if (w == 128 && h == 64) {
w = 320; h = 224; mode = 2;
} else {
if (w == 128 && h == 64) mode = 2;
else if (w == 96 && h == 68) mode = 3;
else {
if (h > w) h = w;
mode = h <= 128;
}
Expand Down
7 changes: 7 additions & 0 deletions fpdoom/keytrn.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ void keytrn_init(void) {
KEY(RSOFT, KEY_MINUS)
KEY(DIAL, KEY_TAB) /* map */
KEY(0, KEY_F11) /* gamma */
/* for cheats */
KEY(1, 'i')
KEY(2, 'd')
KEY(3, 'q')
KEY(4, 'k')
KEY(5, 'f')
KEY(6, 'a')
#undef KEY
};
int i, flags = sys_getkeymap(keymap);
Expand Down
1 change: 1 addition & 0 deletions fpdoom/lcd_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,7 @@ static const uint8_t cmd1230_init[] = {
LCM_DELAY(120),
LCM_CMD(0x2f, 0), // Power Control (VB=1, VR=1, VF=1)
LCM_DELAY(50),
// RR and EV commands seem to be ignored
LCM_CMD(0x24, 0), // Regulation Ratio (4)
LCM_CMD(0x8b, 0), // Electronic Volume (EV=0xb)
//LCM_CMD(0xb0, 0), // Set Page Address
Expand Down
Loading

0 comments on commit a26fd58

Please sign in to comment.