Open
Description
C
#include <stdint.h>
typedef uint8_t u8;
#define MAXMINES 6
extern u8 minex[MAXMINES], miney[MAXMINES], minefloat[MAXMINES], minealive[MAXMINES];
void spawnmine(const u8 x, const u8 y, const u8 floats) {
static u8 i;
for (i = 0; i < MAXMINES; i++) {
if (!minealive[i])
break;
if (i == MAXMINES - 1)
return;
}
minex[i] = x;
miney[i] = y;
minefloat[i] = floats;
minealive[i] = 1;
}
-Oisr asm
.segment "CODE"
jsr pusha
lda #$00
L0026: sta L0006
cmp #$06
bcs L0008
ldy L0006
lda _minealive,y
beq L0008
lda L0006
cmp #$05
beq L0005
clc
adc #$01
jmp L0026
L0008: ldy #$02
lda (sp),y
ldy L0006
sta _minex,y
ldy #$01
lda (sp),y
ldy L0006
sta _miney,y
ldy #$00
lda (sp),y
ldy L0006
sta _minefloat,y
ldy L0006
lda #$01
sta _minealive,y
L0005: jmp incsp3
.endproc
The same value is repeatedly loaded to Y even though it can't possibly have changed. I think this should be easy to detect even in the current pattern-match optimizer.