diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4942a96d..a0695a48 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -214,6 +214,8 @@ C++, Open Watcom, and Visual C++, which will ease future third-party ports. * Macros defining the number of distinct sprites in an animation: `*_CELS` * Frame variables counting from a frame count to 0: `*_time` * Frame variables and other counters starting from 0: `*_frames` +* Generic 0-based IDs: `*_id` +* Generic 1-based IDs, with 0 indicating some sort of absence: `*_num` * Functionally identical reimplementations or micro-optimizations of master.lib functions: `z_` diff --git a/th01/formats/pf.asm b/th01/formats/pf.asm index 8b05712b..0a5f1282 100644 --- a/th01/formats/pf.asm +++ b/th01/formats/pf.asm @@ -81,7 +81,7 @@ loc_17160: jl short loc_1711D loc_17165: - mov _arc_num_files, si + mov _arc_pf_count, si pop di pop si pop bp @@ -127,7 +127,7 @@ loc_17189: push ax call _toupper pop cx - mov dx, _file_num + mov dx, _cur_file_id shl dx, 5 les bx, _arc_pfs add bx, dx @@ -324,7 +324,7 @@ arg_0 = dword ptr 6 push offset aRLE_TYPE mov cx, 3 call SCOPY@ - mov _file_num, 0 + mov _cur_file_id, 0 xor si, si jmp short loc_17306 ; --------------------------------------------------------------------------- @@ -334,15 +334,15 @@ loc_172F6: call @at_pos_of$qnxc or ax, ax jnz short loc_1730C - inc _file_num + inc _cur_file_id inc si loc_17306: - cmp si, _arc_num_files + cmp si, _arc_pf_count jl short loc_172F6 loc_1730C: - mov ax, _file_num + mov ax, _cur_file_id shl ax, 5 mov dx, word ptr _arc_pfs+2 mov bx, word ptr _arc_pfs diff --git a/th01/formats/pf.cpp b/th01/formats/pf.cpp index 251013c3..b02232a7 100644 --- a/th01/formats/pf.cpp +++ b/th01/formats/pf.cpp @@ -12,7 +12,7 @@ extern "C" { #undef arc_file_get -#define MAX_NUM_FILES 64 +#define FILE_COUNT 64 #define CACHE_SIZE 0x100 typedef struct { @@ -29,8 +29,8 @@ typedef struct { pf_header_t *arc_pfs; pf_header_t *file_pf; -int file_num; -int arc_num_files; +int cur_file_id; +int arc_pf_count; char file_compressed; char arc_key; @@ -44,7 +44,7 @@ void pascal arc_load(const char fn[PF_FN_LEN]) { int i, c; - arc_pfs = new pf_header_t[MAX_NUM_FILES]; + arc_pfs = new pf_header_t[FILE_COUNT]; file_ropen(fn); for(i = 0; i < PF_FN_LEN; i++) { arc_fn[i] = fn[i]; @@ -52,9 +52,9 @@ void pascal arc_load(const char fn[PF_FN_LEN]) break; } } - file_read(arc_pfs, sizeof(pf_header_t) * MAX_NUM_FILES); + file_read(arc_pfs, sizeof(pf_header_t) * FILE_COUNT); file_close(); - for(i = 0; i < MAX_NUM_FILES; i++) { + for(i = 0; i < FILE_COUNT; i++) { if(arc_pfs[i].type[0] == 0) { break; } @@ -65,7 +65,7 @@ void pascal arc_load(const char fn[PF_FN_LEN]) arc_pfs[i].fn[c] = ~arc_pfs[i].fn[c]; } } - arc_num_files = i; + arc_pf_count = i; } void pascal arc_free(void) @@ -77,7 +77,7 @@ int pascal near at_pos_of(const char fn[PF_FN_LEN]) { int i; for(i = 0; i < PF_FN_LEN; i++) { - if(arc_pfs[file_num].fn[i] != toupper(fn[i])) { + if(arc_pfs[cur_file_id].fn[i] != toupper(fn[i])) { return 0; } if(fn[i] == 0) { @@ -153,14 +153,14 @@ void pascal arc_file_load(const char fn[PF_FN_LEN]) const char rle_type[] = {"••"}; int i; - file_num = 0; - for(i = 0; i < arc_num_files; i++) { + cur_file_id = 0; + for(i = 0; i < arc_pf_count; i++) { if(at_pos_of(fn)) { break; } - file_num++; + cur_file_id++; } - file_pf = &arc_pfs[file_num]; + file_pf = &arc_pfs[cur_file_id]; file_ropen(arc_fn); file_seek(file_pf->offset, SEEK_SET); if(file_pf->type[0] == rle_type[0] && file_pf->type[1] == rle_type[1]) { diff --git a/th01/formats/pf[bss].asm b/th01/formats/pf[bss].asm index cdae0e64..cfbc7314 100644 --- a/th01/formats/pf[bss].asm +++ b/th01/formats/pf[bss].asm @@ -1,7 +1,7 @@ _arc_pfs dd ? _file_pf dd ? -_file_num dw ? -_arc_num_files dw ? +_cur_file_id dw ? +_arc_pf_count dw ? _file_compressed db ? public _arc_key _arc_key db ? diff --git a/th01/zunsoft.c b/th01/zunsoft.c index 6d3681a6..f488d31f 100644 --- a/th01/zunsoft.c +++ b/th01/zunsoft.c @@ -14,7 +14,7 @@ static char CIRCLE_COLORS[] = {4, 3, 2, 1}; char page_write; char page_show; char tone; -char logo_num; +char logo_patnum; char wave_len; char wave_phase; char wave_amp; @@ -89,7 +89,7 @@ void objects_setup(void) frame = 0; tone = 0; - logo_num = 0; + logo_patnum = 0; wave_len = 23; wave_phase = 0; wave_amp = 0; @@ -168,31 +168,31 @@ void logo_render_and_update(void) } if(frame < 90) { if(frame == 55 || frame == 60 || frame == 65) { - logo_num += 2; + logo_patnum += 2; } - super_put_8(256, 192, logo_num+0); - super_put_8(320, 192, logo_num+1); + super_put_8(256, 192, logo_patnum+0); + super_put_8(320, 192, logo_patnum+1); } else if(frame < 110) { - super_wave_put(256, 192, logo_num+0, wave_len, wave_amp, wave_phase); - super_wave_put(320, 192, logo_num+1, wave_len, wave_amp, wave_phase); + super_wave_put(256, 192, logo_patnum+0, wave_len, wave_amp, wave_phase); + super_wave_put(320, 192, logo_patnum+1, wave_len, wave_amp, wave_phase); wave_len--; wave_phase += 4; wave_amp += 4; } else if(frame < 130) { if(frame == 110) { - logo_num += 2; + logo_patnum += 2; } - super_wave_put(256, 192, logo_num+0, wave_len, wave_amp, wave_phase); - super_wave_put(320, 192, logo_num+1, wave_len, wave_amp, wave_phase); + super_wave_put(256, 192, logo_patnum+0, wave_len, wave_amp, wave_phase); + super_wave_put(320, 192, logo_patnum+1, wave_len, wave_amp, wave_phase); wave_len++; wave_phase += 4; wave_amp -= 4; } else if(frame < 170) { if(frame == 155 || frame == 160 || frame == 165) { - logo_num += 2; + logo_patnum += 2; } - super_put_8(256, 192, logo_num+0); - super_put_8(320, 192, logo_num+1); + super_put_8(256, 192, logo_patnum+0); + super_put_8(320, 192, logo_patnum+1); } } diff --git a/th02/formats/pi.h b/th02/formats/pi.h index 5d0664f6..b363b0be 100644 --- a/th02/formats/pi.h +++ b/th02/formats/pi.h @@ -15,10 +15,10 @@ int DEFCONV pi_slot_load(int slot, const char *fn); void DEFCONV pi_slot_palette_apply(int slot); -// Displays the PI image in slot #[slot] at ([x], [y]). Horizontally, the +// Displays the PI image in slot #[slot] at ([left], [top]). Horizontally, the // image is cut off at 640 pixels; vertically, it is wrapped if it exceeds the // clipping frame defined via grc_setclip(). -void DEFCONV pi_slot_put(int x, int y, int slot); +void DEFCONV pi_slot_put(int left, int top, int slot); #define pi_load_put_free(slot, fn) \ pi_slot_load(slot, (fn)); \ diff --git a/th02/formats/pi_put.c b/th02/formats/pi_put.c index 2013e933..b04870ba 100644 --- a/th02/formats/pi_put.c +++ b/th02/formats/pi_put.c @@ -4,15 +4,15 @@ void pi_slot_palette_apply(int slot) palette_show(); } -void pi_slot_put(int x, int y, int slot) +void pi_slot_put(int left, int top, int slot) { char *row_p = pi_slot_buffers[slot]; - int row_num; - for(row_num = 0; row_num < pi_slot_headers[slot].ysize; row_num++) { - graph_pack_put_8(x, y, row_p, pi_slot_headers[slot].xsize); - y++; - if(y >= RES_Y) { - y -= RES_Y; + int y; + for(y = 0; y < pi_slot_headers[slot].ysize; y++) { + graph_pack_put_8(left, top, row_p, pi_slot_headers[slot].xsize); + top++; + if(top >= RES_Y) { + top -= RES_Y; } row_p += pi_slot_headers[slot].xsize / 2; row_p = MK_FP( diff --git a/th02/formats/pi_slot_put.asm b/th02/formats/pi_slot_put.asm index a84fef93..ae95d93b 100644 --- a/th02/formats/pi_slot_put.asm +++ b/th02/formats/pi_slot_put.asm @@ -1,14 +1,14 @@ proc_defconv pi_slot_put - arg @@x:word, @@y:word, @@slot:word + arg @@left:word, @@top:word, @@slot:word if GAME ge 3 - local @@row_num:word, @@row_buf:dword + local @@y:word, @@row_buf:dword else - local @@row_buf:dword, @@row_num:word + local @@row_buf:dword, @@y:word endif push si push di - mov si, @@y + mov si, @@top mov di, @@slot mov bx, di shl bx, 2 @@ -16,11 +16,11 @@ endif mov dx, word ptr _pi_slot_buffers[bx] mov word ptr @@row_buf+2, ax mov word ptr @@row_buf, dx - mov @@row_num, 0 + mov @@y, 0 jmp short @@check @@put: - push @@x + push @@left push si pushd @@row_buf mov bx, di @@ -47,13 +47,13 @@ endif and dx, 0Fh mov word ptr @@row_buf+2, ax mov word ptr @@row_buf, dx - inc @@row_num + inc @@y @@check: mov bx, di imul bx, size PiHeader mov ax, _pi_slot_headers.PiHeader._ysize[bx] - cmp ax, @@row_num + cmp ax, @@y ja short @@put pop di pop si diff --git a/th05/music/piano.asm b/th05/music/piano.asm index c4dd271f..ef50d5be 100644 --- a/th05/music/piano.asm +++ b/th05/music/piano.asm @@ -91,7 +91,7 @@ _piano_render endp ; void __usercall near piano_part_render( ; void far *vram_at_x0_and_top_of_part, -; int fm_part_num, +; int fm_part_id, ; QQ **pmd_part, ; void __seg own_ds ; );