mirror of https://github.com/nmlgc/ReC98.git
[Maintenance] Adopt the peek() and poke() inline functions from <dos.h>
Which still allows us to replace a bunch of manual MK_FP() macros with calls to these functions. Part of P0157, funded by Yanga.
This commit is contained in:
parent
4bc6405543
commit
af2c0e14a4
|
@ -56,11 +56,6 @@ void grx_put_col(unsigned int slot, uint4_t col)
|
|||
grx_col = 0;
|
||||
}
|
||||
|
||||
inline void vram_put(seg_t segment, uint16_t offset, dots8_t dots)
|
||||
{
|
||||
*reinterpret_cast<dots8_t far *>(MK_FP(segment, offset)) = dots;
|
||||
}
|
||||
|
||||
void grx_put(unsigned int slot)
|
||||
{
|
||||
uint8_t command;
|
||||
|
@ -70,12 +65,12 @@ void grx_put(unsigned int slot)
|
|||
|
||||
#define put(vram_offset, vram_offset_last, planar) \
|
||||
if(!grx_col) { \
|
||||
vram_put(SEG_PLANE_B, vram_offset, *(planar++)); \
|
||||
vram_put(SEG_PLANE_R, vram_offset, *(planar++)); \
|
||||
vram_put(SEG_PLANE_G, vram_offset, *(planar++)); \
|
||||
vram_put(SEG_PLANE_E, vram_offset_last, *(planar++)); \
|
||||
pokeb(SEG_PLANE_B, vram_offset, *(planar++)); \
|
||||
pokeb(SEG_PLANE_R, vram_offset, *(planar++)); \
|
||||
pokeb(SEG_PLANE_G, vram_offset, *(planar++)); \
|
||||
pokeb(SEG_PLANE_E, vram_offset_last, *(planar++)); \
|
||||
} else { \
|
||||
vram_put(SEG_PLANE_B, vram_offset_last, 0xFF); \
|
||||
pokeb(SEG_PLANE_B, vram_offset_last, 0xFF); \
|
||||
}
|
||||
|
||||
if(grx_col) {
|
||||
|
|
|
@ -85,7 +85,7 @@ void z_text_hide(void)
|
|||
|
||||
void z_text_setcursor(z_text_cursor_t type)
|
||||
{
|
||||
_BX = *(char*)MK_FP(0, 0x53B);
|
||||
_BX = peekb(0, 0x53B); // Text mode line height
|
||||
outportb(0x62, 0x4B); // CSRFORM
|
||||
outportb(0x60, _BL | 0x80);
|
||||
switch(type) {
|
||||
|
|
|
@ -22,7 +22,7 @@ vram_y_t pascal near scroll_subpixel_y_to_vram_seg3(subpixel_t y)
|
|||
#define ret static_cast<vram_y_t>(_AX) // Must be signed!
|
||||
|
||||
_BX = _SP;
|
||||
ret = *reinterpret_cast<vram_y_t *>(MK_FP(_SS, _BX + 2)); /* = */ (y);
|
||||
ret = peek(_SS, (_BX + 2)); /* = */ (y);
|
||||
|
||||
ret = TO_PIXEL(ret);
|
||||
if(scroll_active) {
|
||||
|
@ -39,7 +39,7 @@ vram_y_t pascal near scroll_subpixel_y_to_vram_always(subpixel_t y)
|
|||
#define ret static_cast<vram_y_t>(_AX) // Must be signed!
|
||||
|
||||
_BX = _SP;
|
||||
ret = *reinterpret_cast<vram_y_t *>(MK_FP(_SS, _BX + 2)); /* = */ (y);
|
||||
ret = peek(_SS, (_BX + 2)); /* = */ (y);
|
||||
|
||||
ret = (TO_PIXEL(ret) + scroll_line);
|
||||
ret = roll(ret);
|
||||
|
|
|
@ -35,7 +35,7 @@ static inline bool16 snd_se_active() {
|
|||
// MODDERS: Just use [new_se] directly.
|
||||
static inline int16_t snd_get_param(int16_t ¶m) {
|
||||
_BX = _SP;
|
||||
return *reinterpret_cast<int *>(MK_FP(_SS, (_BX + 4)));
|
||||
return peek(_SS, (_BX + 4));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
23
x86real.h
23
x86real.h
|
@ -96,10 +96,25 @@ int int86(int __intno, union REGS *__inregs, union REGS *__outregs);
|
|||
#define FP_SEG(fp) ((uint16_t)(void __seg *)(void __far *)(fp))
|
||||
#define FP_OFF(fp) ((uint16_t)(fp))
|
||||
|
||||
#define peek(a,b) (*((int16_t __far * )MK_FP((a),(b))))
|
||||
#define peekb(a,b) (*(( int8_t __far * )MK_FP((a),(b))))
|
||||
#define poke(a,b,c) (*((int16_t __far * )MK_FP((a),(b))) = (int16_t)(c))
|
||||
#define pokeb(a,b,c) (*(( int8_t __far * )MK_FP((a),(b))) = ( int8_t)(c))
|
||||
#ifdef __cplusplus
|
||||
int16_t inline peek(uint16_t __segment, uint16_t __offset) {
|
||||
return (*((int16_t __far *)MK_FP(__segment, __offset)));
|
||||
}
|
||||
int8_t inline peekb(uint16_t __segment, uint16_t __offset) {
|
||||
return (*((int8_t __far *)MK_FP(__segment, __offset)));
|
||||
}
|
||||
void inline poke(uint16_t __segment, uint16_t __offset, int16_t __value) {
|
||||
(*((int16_t __far *)MK_FP(__segment, __offset)) = __value);
|
||||
}
|
||||
void inline pokeb(uint16_t __segment, uint16_t __offset, int8_t __value) {
|
||||
(*((int8_t __far *)MK_FP(__segment, __offset)) = __value);
|
||||
}
|
||||
#else
|
||||
#define peek(a,b) (*((int16_t __far * )MK_FP((a),(b))))
|
||||
#define peekb(a,b) (*(( int8_t __far * )MK_FP((a),(b))))
|
||||
#define poke(a,b,c) (*((int16_t __far * )MK_FP((a),(b))) = (int16_t)(c))
|
||||
#define pokeb(a,b,c) (*(( int8_t __far * )MK_FP((a),(b))) = ( int8_t)(c))
|
||||
#endif
|
||||
/// ----------------
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue