Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C decompilation] [th01] VSync interrupt handler
Time to get back into this.
- Loading branch information
Showing
12 changed files
with
209 additions
and
830 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* ReC98 | ||
* ----- | ||
* Code segment #5 of TH01's FUUIN.EXE | ||
*/ | ||
|
||
#include "th01/hardware/vsync.c" | ||
#include "th01/hardware/vsyncclr.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* ReC98 | ||
* ----- | ||
* VSync interrupt handler | ||
*/ | ||
|
||
#include "th01/th01.h" | ||
|
||
#pragma option -2 | ||
#pragma warn -aus | ||
|
||
extern char vsync_initialized; | ||
extern int vsync_callback_is_set; | ||
|
||
extern int RES_X_HALF; | ||
extern int RES_Y_HALF; | ||
|
||
extern int vsync_frame; | ||
extern int vsync_unused; | ||
extern void interrupt (*vsync_callback_old)(void); | ||
extern void (*vsync_callback)(void); | ||
|
||
static void interrupt vsync_intfunc(void) | ||
{ | ||
int res_x_half = RES_X_HALF; | ||
int res_y_half = RES_Y_HALF; | ||
vsync_frame++; | ||
vsync_unused++; | ||
if(vsync_callback_is_set) { | ||
vsync_callback(); | ||
} | ||
OUTB(0x00, 0x20); // End of Interrupt | ||
OUTB(0x64, 0); // VSync interrupt trigger | ||
} | ||
|
||
void vsync_init(void) | ||
{ | ||
if(vsync_initialized == 0) { | ||
vsync_initialized = 1; | ||
disable(); | ||
vsync_callback_old = getvect(0x0A); | ||
setvect(0x0A, vsync_intfunc); | ||
|
||
// Disable all interrupts from 0x08 to 0x0F except for 0x0A | ||
OUTB(0x02, INPB(0x02) & 0xFB); | ||
|
||
OUTB(0x64, 0); // VSync interrupt trigger | ||
enable(); | ||
} | ||
} | ||
|
||
void vsync_exit(void) | ||
{ | ||
if(vsync_initialized == 1) { | ||
vsync_initialized = 0; | ||
disable(); | ||
|
||
// Reenable all interrupts from 0x08 to 0x0F except for 0x0A | ||
OUTB(0x02, INPB(0x02) | 0x04); | ||
|
||
setvect(0x0a, vsync_callback_old); | ||
enable(); | ||
} | ||
} | ||
|
||
void z_vsync_wait(void) | ||
{ | ||
do { | ||
_AL = INPB(0x60); | ||
} while((_AL & 0x20) != 0); | ||
do { | ||
_AL = INPB(0x60); | ||
} while((_AL & 0x20) == 0); | ||
} | ||
|
||
void vsync_callback_set(void (*vsync_callback_new)()) | ||
{ | ||
vsync_callback_is_set = 0; | ||
vsync_callback = vsync_callback_new; | ||
vsync_callback_is_set = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public _vsync_frame, _vsync_unused, _vsync_callback_old, _vsync_callback | ||
_vsync_frame dw ? | ||
_vsync_unused dw ? | ||
_vsync_callback_old dd ? | ||
_vsync_callback dd ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
public _vsync_initialized, _vsync_callback_is_set, _RES_X_HALF, _RES_Y_HALF | ||
_vsync_initialized db 0 | ||
_vsync_callback_is_set dw 0 | ||
dd 7 | ||
dd 0 | ||
_RES_X_HALF dw 320 | ||
_RES_Y_HALF dw 200 | ||
|
||
; Unused? | ||
dw 0 | ||
dw 0 | ||
dw 639 | ||
dw 399 | ||
dw 0C000h | ||
dw 0E000h | ||
dw 0F000h | ||
dw 0F800h | ||
dw 0FC00h | ||
dw 0FE00h | ||
dw 0FF00h | ||
dw 0FF80h | ||
dw 0FFC0h | ||
dw 0FFE0h | ||
dw 0FE00h | ||
dw 0EF00h | ||
dw 0CF00h | ||
dw 780h | ||
dw 780h | ||
dw 300h | ||
dw 0 | ||
dw 4000h | ||
dw 6000h | ||
dw 7000h | ||
dw 7800h | ||
dw 7C00h | ||
dw 7E00h | ||
dw 7F00h | ||
dw 7F80h | ||
dw 7C00h | ||
dw 6C00h | ||
dw 4600h | ||
dw 600h | ||
dw 300h | ||
dw 300h | ||
dw 0 | ||
db 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* ReC98 | ||
* ----- | ||
* VSync interrupt callback clear function. In REIIDEN.EXE, this function needs | ||
* to be put into a segment separate from vsync.c. | ||
*/ | ||
|
||
extern int vsync_callback_is_set; | ||
|
||
void vsync_callback_clear(void) | ||
{ | ||
vsync_callback_is_set = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* ReC98 | ||
* ----- | ||
* Code segment #3 of TH01's REIIDEN.EXE | ||
*/ | ||
|
||
#include "th01/hardware/vsync.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
* Code segment #4 of TH01's REIIDEN.EXE | ||
*/ | ||
|
||
#include "th01/hardware/vsyncclr.c" | ||
#include "th01/ztext.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* ReC98 | ||
* ----- | ||
* Code segment #3 of TH01's OP.EXE | ||
*/ | ||
|
||
#include "th01/hardware/vsync.c" | ||
#include "th01/hardware/vsyncclr.c" |
Oops, something went wrong.