mirror of
https://github.com/jeremysrand/a2bejwld.git
synced 2024-06-25 23:29:27 +00:00
More code simplification thanks to the more generalized assembly draw code.
This commit is contained in:
parent
db767afb5d
commit
563258d77a
101
a2bejwld/anim.c
101
a2bejwld/anim.c
|
@ -115,94 +115,33 @@ static tClearGemHandler gClearGemHandler[] = {
|
||||||
|
|
||||||
void drawGemAtSquare(tSquare square)
|
void drawGemAtSquare(tSquare square)
|
||||||
{
|
{
|
||||||
switch (gemTypeAtSquare(square)) {
|
static uint8_t tempSquare;
|
||||||
case GEM_GREEN:
|
static uint8_t tempGemType;
|
||||||
drawGreenGem(square);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GEM_RED:
|
tempGemType = gemTypeAtSquare(square);
|
||||||
drawRedGem(square);
|
tempSquare = square;
|
||||||
break;
|
|
||||||
|
|
||||||
case GEM_PURPLE:
|
__asm__("lda %v", tempSquare);
|
||||||
drawPurpleGem(square);
|
__asm__("ldy %v", tempGemType);
|
||||||
break;
|
__asm__("jsr _drawGem");
|
||||||
|
|
||||||
case GEM_ORANGE:
|
|
||||||
drawOrangeGem(square);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GEM_GREY:
|
|
||||||
drawGreyGem(square);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GEM_YELLOW:
|
|
||||||
drawYellowGem(square);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GEM_BLUE:
|
|
||||||
drawBlueGem(square);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GEM_SPECIAL:
|
|
||||||
drawSpecialGem(square);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void drawGemAtXY(uint8_t x, uint8_t y, tGemType gemType, bool starred)
|
static void drawGemAtXYWrapper(uint8_t x, uint8_t y, tGemType gemType, bool starred)
|
||||||
{
|
{
|
||||||
static uint8_t tempX;
|
static uint8_t tempX;
|
||||||
|
static uint8_t tempY;
|
||||||
|
static uint8_t tempGemType;
|
||||||
|
|
||||||
|
tempY = y;
|
||||||
tempX = x;
|
tempX = x;
|
||||||
switch (gemType) {
|
tempGemType = gemType;
|
||||||
case GEM_GREEN:
|
|
||||||
__asm__("ldx %v", tempX);
|
|
||||||
drawGreenGemAtXY(y);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GEM_RED:
|
__asm__("lda %v", tempY);
|
||||||
__asm__("ldx %v", tempX);
|
__asm__("ldx %v", tempX);
|
||||||
drawRedGemAtXY(y);
|
__asm__("ldy %v", tempGemType);
|
||||||
break;
|
__asm__("jsr _drawGemAtXY");
|
||||||
|
|
||||||
case GEM_PURPLE:
|
|
||||||
__asm__("ldx %v", tempX);
|
|
||||||
drawPurpleGemAtXY(y);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GEM_ORANGE:
|
|
||||||
__asm__("ldx %v", tempX);
|
|
||||||
drawOrangeGemAtXY(y);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GEM_GREY:
|
|
||||||
__asm__("ldx %v", tempX);
|
|
||||||
drawGreyGemAtXY(y);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GEM_YELLOW:
|
|
||||||
__asm__("ldx %v", tempX);
|
|
||||||
drawYellowGemAtXY(y);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GEM_BLUE:
|
|
||||||
__asm__("ldx %v", tempX);
|
|
||||||
drawBlueGemAtXY(y);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GEM_SPECIAL:
|
|
||||||
__asm__("ldx %v", tempX);
|
|
||||||
drawSpecialGemAtXY(y);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (starred) {
|
if (starred) {
|
||||||
__asm__("ldx %v", tempX);
|
__asm__("ldx %v", tempX);
|
||||||
starGemAtXY(y);
|
starGemAtXY(y);
|
||||||
|
@ -406,8 +345,8 @@ void swapSquares(tSquare square1, tGemType gemType1, bool starred1,
|
||||||
gVblWait();
|
gVblWait();
|
||||||
drawBgSquare(square1);
|
drawBgSquare(square1);
|
||||||
drawBgSquare(square2);
|
drawBgSquare(square2);
|
||||||
drawGemAtXY(x1, y1, gemType1, starred1);
|
drawGemAtXYWrapper(x1, y1, gemType1, starred1);
|
||||||
drawGemAtXY(x2, y2, gemType2, starred2);
|
drawGemAtXYWrapper(x2, y2, gemType2, starred2);
|
||||||
#ifdef DEBUG_SWAP_ANIM
|
#ifdef DEBUG_SWAP_ANIM
|
||||||
cgetc();
|
cgetc();
|
||||||
#endif
|
#endif
|
||||||
|
@ -420,8 +359,8 @@ void swapSquares(tSquare square1, tGemType gemType1, bool starred1,
|
||||||
gVblWait();
|
gVblWait();
|
||||||
drawBgSquare(square1);
|
drawBgSquare(square1);
|
||||||
drawBgSquare(square2);
|
drawBgSquare(square2);
|
||||||
drawGemAtXY(x1, y1, gemType1, starred1);
|
drawGemAtXYWrapper(x1, y1, gemType1, starred1);
|
||||||
drawGemAtXY(x2, y2, gemType2, starred2);
|
drawGemAtXYWrapper(x2, y2, gemType2, starred2);
|
||||||
#ifdef DEBUG_SWAP_ANIM
|
#ifdef DEBUG_SWAP_ANIM
|
||||||
cgetc();
|
cgetc();
|
||||||
#endif
|
#endif
|
||||||
|
@ -585,7 +524,7 @@ void endDropAnim(void)
|
||||||
if (!gemInfo->visible)
|
if (!gemInfo->visible)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
drawGemAtXY(gemInfo->x, gemInfo->y - 24, gemInfo->gemType, gemInfo->starred);
|
drawGemAtXYWrapper(gemInfo->x, gemInfo->y - 24, gemInfo->gemType, gemInfo->starred);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_DROP_ANIM
|
#ifdef DEBUG_DROP_ANIM
|
||||||
cgetc();
|
cgetc();
|
||||||
|
|
|
@ -21,14 +21,7 @@ extern void __fastcall__ mixedTextMode(void);
|
||||||
|
|
||||||
extern void __fastcall__ drawBgSquare(tSquare square);
|
extern void __fastcall__ drawBgSquare(tSquare square);
|
||||||
|
|
||||||
extern void __fastcall__ drawBlueGem(tSquare square);
|
extern void __fastcall__ drawGem(tSquare square);
|
||||||
extern void __fastcall__ drawYellowGem(tSquare square);
|
|
||||||
extern void __fastcall__ drawRedGem(tSquare square);
|
|
||||||
extern void __fastcall__ drawGreenGem(tSquare square);
|
|
||||||
extern void __fastcall__ drawOrangeGem(tSquare square);
|
|
||||||
extern void __fastcall__ drawGreyGem(tSquare square);
|
|
||||||
extern void __fastcall__ drawPurpleGem(tSquare square);
|
|
||||||
extern void __fastcall__ drawSpecialGem(tSquare square);
|
|
||||||
|
|
||||||
extern void __fastcall__ explodeGemFrame1(tSquare square);
|
extern void __fastcall__ explodeGemFrame1(tSquare square);
|
||||||
extern void __fastcall__ explodeGemFrame2(tSquare square);
|
extern void __fastcall__ explodeGemFrame2(tSquare square);
|
||||||
|
@ -46,15 +39,9 @@ extern void __fastcall__ drawScore(uint8_t score);
|
||||||
|
|
||||||
// The following functions take the Y position (0-23) as
|
// The following functions take the Y position (0-23) as
|
||||||
// their first argument. The X position (0-39) should
|
// their first argument. The X position (0-39) should
|
||||||
// be in the X register.
|
// be in the X register. The gem type should be in the
|
||||||
extern void __fastcall__ drawBlueGemAtXY(uint8_t y);
|
// Y register.
|
||||||
extern void __fastcall__ drawYellowGemAtXY(uint8_t y);
|
extern void __fastcall__ drawGemAtXY(uint8_t y);
|
||||||
extern void __fastcall__ drawRedGemAtXY(uint8_t y);
|
|
||||||
extern void __fastcall__ drawGreenGemAtXY(uint8_t y);
|
|
||||||
extern void __fastcall__ drawOrangeGemAtXY(uint8_t y);
|
|
||||||
extern void __fastcall__ drawGreyGemAtXY(uint8_t y);
|
|
||||||
extern void __fastcall__ drawPurpleGemAtXY(uint8_t y);
|
|
||||||
extern void __fastcall__ drawSpecialGemAtXY(uint8_t y);
|
|
||||||
|
|
||||||
extern void __fastcall__ starGemAtXY(uint8_t y);
|
extern void __fastcall__ starGemAtXY(uint8_t y);
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,10 @@
|
||||||
.export _showDblLoRes, _clearDblLoRes, _unshowDblLoRes
|
.export _showDblLoRes, _clearDblLoRes, _unshowDblLoRes
|
||||||
.export _mixedTextMode
|
.export _mixedTextMode
|
||||||
|
|
||||||
.export _drawGreenGem, _drawPurpleGem, _drawYellowGem
|
.export _drawGem, _drawBgSquare
|
||||||
.export _drawBlueGem, _drawRedGem, _drawGreyGem
|
|
||||||
.export _drawOrangeGem, _drawSpecialGem, _drawBgSquare
|
|
||||||
.export _drawScore, _selectSquare, _starGem
|
.export _drawScore, _selectSquare, _starGem
|
||||||
|
|
||||||
.export _drawGreenGemAtXY, _drawPurpleGemAtXY, _drawYellowGemAtXY
|
.export _drawGemAtXY, _starGemAtXY
|
||||||
.export _drawBlueGemAtXY, _drawRedGemAtXY, _drawGreyGemAtXY
|
|
||||||
.export _drawOrangeGemAtXY, _drawSpecialGemAtXY, _starGemAtXY
|
|
||||||
|
|
||||||
.export _explodeGemFrame1, _explodeGemFrame2
|
.export _explodeGemFrame1, _explodeGemFrame2
|
||||||
.export _explodeGemFrame3, _explodeGemFrame4
|
.export _explodeGemFrame3, _explodeGemFrame4
|
||||||
|
@ -58,14 +54,12 @@ LINE24 := $7d0
|
||||||
;line1addr: .WORD $0
|
;line1addr: .WORD $0
|
||||||
;line2addr: .WORD $0
|
;line2addr: .WORD $0
|
||||||
;line3addr: .WORD $0
|
;line3addr: .WORD $0
|
||||||
;gemaddr: .WORD $0
|
|
||||||
;gemmask: .WORD $0
|
;gemmask: .WORD $0
|
||||||
|
|
||||||
line1addr := $82
|
line1addr := $82
|
||||||
line2addr := $84
|
line2addr := $84
|
||||||
line3addr := $86
|
line3addr := $86
|
||||||
gemaddr := $88
|
gemmask := $88
|
||||||
gemmask := $8A
|
|
||||||
|
|
||||||
.CODE
|
.CODE
|
||||||
|
|
||||||
|
@ -131,6 +125,7 @@ gemmask := $8A
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
.proc _clearDblLoRes
|
.proc _clearDblLoRes
|
||||||
sta LOWSCR
|
sta LOWSCR
|
||||||
ldx #40
|
ldx #40
|
||||||
|
@ -417,90 +412,6 @@ square: .BYTE $0
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
.proc _drawGreenGem
|
|
||||||
ldy #1
|
|
||||||
jmp _drawGem
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
|
|
||||||
.proc _drawGreenGemAtXY
|
|
||||||
ldy #1
|
|
||||||
jmp _drawGemAtXY
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
|
|
||||||
.proc _drawPurpleGem
|
|
||||||
ldy #3
|
|
||||||
jmp _drawGem
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
|
|
||||||
.proc _drawPurpleGemAtXY
|
|
||||||
ldy #3
|
|
||||||
jmp _drawGemAtXY
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
|
|
||||||
.proc _drawYellowGem
|
|
||||||
ldy #6
|
|
||||||
jmp _drawGem
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc _drawYellowGemAtXY
|
|
||||||
ldy #6
|
|
||||||
jmp _drawGemAtXY
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc _drawBlueGem
|
|
||||||
ldy #7
|
|
||||||
jmp _drawGem
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc _drawBlueGemAtXY
|
|
||||||
ldy #7
|
|
||||||
jmp _drawGemAtXY
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc _drawRedGem
|
|
||||||
ldy #2
|
|
||||||
jmp _drawGem
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc _drawRedGemAtXY
|
|
||||||
ldy #2
|
|
||||||
jmp _drawGemAtXY
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc _drawGreyGem
|
|
||||||
ldy #5
|
|
||||||
jmp _drawGem
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc _drawGreyGemAtXY
|
|
||||||
ldy #5
|
|
||||||
jmp _drawGemAtXY
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc _drawOrangeGem
|
|
||||||
ldy #4
|
|
||||||
jmp _drawGem
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc _drawOrangeGemAtXY
|
|
||||||
ldy #4
|
|
||||||
jmp _drawGemAtXY
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc _drawSpecialGem
|
|
||||||
ldy #8
|
|
||||||
jmp _drawGem
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc _drawSpecialGemAtXY
|
|
||||||
ldy #8
|
|
||||||
jmp _drawGemAtXY
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc _selectSquare
|
.proc _selectSquare
|
||||||
ldy #0
|
ldy #0
|
||||||
jmp _drawGem
|
jmp _drawGem
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user