mirror of
https://github.com/jeremysrand/a2bejwld.git
synced 2024-09-27 03:54:47 +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)
|
||||
{
|
||||
switch (gemTypeAtSquare(square)) {
|
||||
case GEM_GREEN:
|
||||
drawGreenGem(square);
|
||||
break;
|
||||
static uint8_t tempSquare;
|
||||
static uint8_t tempGemType;
|
||||
|
||||
case GEM_RED:
|
||||
drawRedGem(square);
|
||||
break;
|
||||
tempGemType = gemTypeAtSquare(square);
|
||||
tempSquare = square;
|
||||
|
||||
case GEM_PURPLE:
|
||||
drawPurpleGem(square);
|
||||
break;
|
||||
|
||||
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;
|
||||
}
|
||||
__asm__("lda %v", tempSquare);
|
||||
__asm__("ldy %v", tempGemType);
|
||||
__asm__("jsr _drawGem");
|
||||
}
|
||||
|
||||
|
||||
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 tempY;
|
||||
static uint8_t tempGemType;
|
||||
|
||||
tempY = y;
|
||||
tempX = x;
|
||||
switch (gemType) {
|
||||
case GEM_GREEN:
|
||||
__asm__("ldx %v", tempX);
|
||||
drawGreenGemAtXY(y);
|
||||
break;
|
||||
tempGemType = gemType;
|
||||
|
||||
case GEM_RED:
|
||||
__asm__("lda %v", tempY);
|
||||
__asm__("ldx %v", tempX);
|
||||
drawRedGemAtXY(y);
|
||||
break;
|
||||
__asm__("ldy %v", tempGemType);
|
||||
__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) {
|
||||
__asm__("ldx %v", tempX);
|
||||
starGemAtXY(y);
|
||||
@ -406,8 +345,8 @@ void swapSquares(tSquare square1, tGemType gemType1, bool starred1,
|
||||
gVblWait();
|
||||
drawBgSquare(square1);
|
||||
drawBgSquare(square2);
|
||||
drawGemAtXY(x1, y1, gemType1, starred1);
|
||||
drawGemAtXY(x2, y2, gemType2, starred2);
|
||||
drawGemAtXYWrapper(x1, y1, gemType1, starred1);
|
||||
drawGemAtXYWrapper(x2, y2, gemType2, starred2);
|
||||
#ifdef DEBUG_SWAP_ANIM
|
||||
cgetc();
|
||||
#endif
|
||||
@ -420,8 +359,8 @@ void swapSquares(tSquare square1, tGemType gemType1, bool starred1,
|
||||
gVblWait();
|
||||
drawBgSquare(square1);
|
||||
drawBgSquare(square2);
|
||||
drawGemAtXY(x1, y1, gemType1, starred1);
|
||||
drawGemAtXY(x2, y2, gemType2, starred2);
|
||||
drawGemAtXYWrapper(x1, y1, gemType1, starred1);
|
||||
drawGemAtXYWrapper(x2, y2, gemType2, starred2);
|
||||
#ifdef DEBUG_SWAP_ANIM
|
||||
cgetc();
|
||||
#endif
|
||||
@ -585,7 +524,7 @@ void endDropAnim(void)
|
||||
if (!gemInfo->visible)
|
||||
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
|
||||
cgetc();
|
||||
|
@ -21,14 +21,7 @@ extern void __fastcall__ mixedTextMode(void);
|
||||
|
||||
extern void __fastcall__ drawBgSquare(tSquare square);
|
||||
|
||||
extern void __fastcall__ drawBlueGem(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__ drawGem(tSquare square);
|
||||
|
||||
extern void __fastcall__ explodeGemFrame1(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
|
||||
// their first argument. The X position (0-39) should
|
||||
// be in the X register.
|
||||
extern void __fastcall__ drawBlueGemAtXY(uint8_t y);
|
||||
extern void __fastcall__ drawYellowGemAtXY(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);
|
||||
// be in the X register. The gem type should be in the
|
||||
// Y register.
|
||||
extern void __fastcall__ drawGemAtXY(uint8_t y);
|
||||
|
||||
extern void __fastcall__ starGemAtXY(uint8_t y);
|
||||
|
||||
|
@ -9,14 +9,10 @@
|
||||
.export _showDblLoRes, _clearDblLoRes, _unshowDblLoRes
|
||||
.export _mixedTextMode
|
||||
|
||||
.export _drawGreenGem, _drawPurpleGem, _drawYellowGem
|
||||
.export _drawBlueGem, _drawRedGem, _drawGreyGem
|
||||
.export _drawOrangeGem, _drawSpecialGem, _drawBgSquare
|
||||
.export _drawGem, _drawBgSquare
|
||||
.export _drawScore, _selectSquare, _starGem
|
||||
|
||||
.export _drawGreenGemAtXY, _drawPurpleGemAtXY, _drawYellowGemAtXY
|
||||
.export _drawBlueGemAtXY, _drawRedGemAtXY, _drawGreyGemAtXY
|
||||
.export _drawOrangeGemAtXY, _drawSpecialGemAtXY, _starGemAtXY
|
||||
.export _drawGemAtXY, _starGemAtXY
|
||||
|
||||
.export _explodeGemFrame1, _explodeGemFrame2
|
||||
.export _explodeGemFrame3, _explodeGemFrame4
|
||||
@ -58,14 +54,12 @@ LINE24 := $7d0
|
||||
;line1addr: .WORD $0
|
||||
;line2addr: .WORD $0
|
||||
;line3addr: .WORD $0
|
||||
;gemaddr: .WORD $0
|
||||
;gemmask: .WORD $0
|
||||
|
||||
line1addr := $82
|
||||
line2addr := $84
|
||||
line3addr := $86
|
||||
gemaddr := $88
|
||||
gemmask := $8A
|
||||
gemmask := $88
|
||||
|
||||
.CODE
|
||||
|
||||
@ -131,6 +125,7 @@ gemmask := $8A
|
||||
rts
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _clearDblLoRes
|
||||
sta LOWSCR
|
||||
ldx #40
|
||||
@ -417,90 +412,6 @@ square: .BYTE $0
|
||||
.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
|
||||
ldy #0
|
||||
jmp _drawGem
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user