3 Commits

14 changed files with 107 additions and 82 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <sys/stat.h>
const int MAXLENGTH = 0x300;
@@ -7,11 +8,11 @@ const int MAXLENGTH = 0x300;
struct section {
int mode;
int length;
char data[2];
unsigned char data[2];
int datalength;
};
int find_duplicate(off_t loc, off_t size, char buf[], struct section *out) {
int find_duplicate(off_t loc, off_t size, unsigned char buf[], struct section *out) {
int i, j;
struct section result;
result.mode = 4;
@@ -39,7 +40,7 @@ int find_duplicate(off_t loc, off_t size, char buf[], struct section *out) {
return 0;
}
int find_repeat_byte(off_t loc, off_t size, char buf[], struct section *out) {
int find_repeat_byte(off_t loc, off_t size, unsigned char buf[], struct section *out) {
int i;
for (i = 0; i < MAXLENGTH && loc + i < size; i++) {
if (buf[loc + i] != buf[loc]) {
@@ -58,7 +59,7 @@ int find_repeat_byte(off_t loc, off_t size, char buf[], struct section *out) {
return -1;
}
int find_repeat_word(off_t loc, off_t size, char buf[], struct section *out) {
int find_repeat_word(off_t loc, off_t size, unsigned char buf[], struct section *out) {
int i;
for (i = 0; i < MAXLENGTH && loc + i + 1 < size; i += 1) {
if (buf[loc + i] != buf[loc + (i & 1)]) {
@@ -78,7 +79,7 @@ int find_repeat_word(off_t loc, off_t size, char buf[], struct section *out) {
return -1;
}
int find_incrementing_byte(off_t loc, off_t size, char buf[], struct section *out) {
int find_incrementing_byte(off_t loc, off_t size, unsigned char buf[], struct section *out) {
int i;
for (i = 0; i < MAXLENGTH && loc + i < size; i++) {
if (buf[loc] + i < i) {
@@ -100,7 +101,7 @@ int find_incrementing_byte(off_t loc, off_t size, char buf[], struct section *ou
return -1;
}
int get_section(off_t loc, off_t size, char buf[], struct section *out) {
int get_section(off_t loc, off_t size, unsigned char buf[], struct section *out) {
struct section best, current;
best.length = 0;
if (!find_repeat_byte(loc, size, buf, &current)) {
@@ -132,7 +133,7 @@ int get_section(off_t loc, off_t size, char buf[], struct section *out) {
}
}
int write_section(struct section section, char data[], char buf[], int loc) {
int write_section(struct section section, unsigned char data[], unsigned char buf[], int loc) {
int nloc = loc;
int len = section.length - 1;
if (len > 0x1F) {
@@ -149,10 +150,15 @@ int write_section(struct section section, char data[], char buf[], int loc) {
int main(int argc, char *argv[]) {
if (argc < 3) {
printf("Usage: %s infile outfile\n", argv[0]);
printf("Usage: %s infile outfile [start [length]]\n", argv[0]);
return 1;
}
off_t seek = 0;
if (argc > 3) {
seek = strtol(argv[3], NULL, 0);
}
FILE *inptr;
if ((inptr = fopen(argv[1], "rb")) == NULL) {
printf("%s does not exist.\n", argv[1]);
@@ -170,9 +176,14 @@ int main(int argc, char *argv[]) {
printf("Error stating file: %s\n", argv[1]);
return 1;
}
off_t size = buf.st_size;
off_t size = buf.st_size - seek;
char inbuf[size];
if (argc > 4) {
size = strtol(argv[4], NULL, 0);
}
unsigned char inbuf[size];
fseek(inptr, seek, SEEK_SET);
if (fread(inbuf, 1, size, inptr) < size) {
printf("Error reading file: %s\n", argv[1]);
@@ -181,9 +192,8 @@ int main(int argc, char *argv[]) {
fclose(inptr);
char outbuf[size * 2];
char m0data[MAXLENGTH];
unsigned char outbuf[size * 2];
unsigned char m0data[MAXLENGTH];
int oloc = 0;
struct section m0;
@@ -233,7 +243,7 @@ int main(int argc, char *argv[]) {
}
fclose(outptr);
printf("Input file: %X bytes. Compressed: %X bytes.\n", size, oloc);
printf("Input file: %lX bytes. Compressed: %X bytes.\n", size, oloc);
return 0;
}

View File

@@ -1,21 +1,20 @@
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <sys/stat.h>
struct section {
int mode;
int length;
char data[2];
unsigned char data[2];
int datalength;
};
int read_section(char buf[], int loc, struct section *out) {
int read_section(unsigned char buf[], int loc, struct section *out) {
int nloc = loc;
char header = buf[nloc++];
unsigned char header = buf[nloc++];
printf("%x: ", header & 0xff);
if (header == -1) {
if (header == 0xFF) {
return -1;
}
@@ -31,8 +30,6 @@ int read_section(char buf[], int loc, struct section *out) {
result.length = (header & 0x1F) + 1;
}
printf("%d: %x\n", result.mode, result.length);
switch (result.mode) {
case 0:
result.datalength = 0;
@@ -61,10 +58,15 @@ int read_section(char buf[], int loc, struct section *out) {
int main(int argc, char *argv[]) {
if (argc < 3) {
printf("Usage: %s infile outfile\n", argv[0]);
printf("Usage: %s infile outfile [start [length]]\n", argv[0]);
return 1;
}
off_t seek = 0;
if (argc > 3) {
seek = strtol(argv[3], NULL, 0);
}
FILE *inptr;
if ((inptr = fopen(argv[1], "rb")) == NULL) {
printf("%s does not exist.\n", argv[1]);
@@ -82,9 +84,15 @@ int main(int argc, char *argv[]) {
printf("Error stating file: %s\n", argv[1]);
return 1;
}
off_t size = buf.st_size;
char inbuf[size];
off_t size = buf.st_size - seek;
if (argc > 4) {
size = strtol(argv[4], NULL, 0);
}
fseek(inptr, seek, SEEK_SET);
unsigned char inbuf[size];
if (fread(inbuf, 1, size, inptr) < size) {
printf("Error reading file: %s\n", argv[1]);
@@ -93,7 +101,7 @@ int main(int argc, char *argv[]) {
fclose(inptr);
char outbuf[size * 256];
unsigned char outbuf[size * 256];
int oloc = 0;
struct section section;
@@ -141,7 +149,7 @@ int main(int argc, char *argv[]) {
}
fclose(outptr);
printf("Input file: %X bytes. Decompressed: %X bytes.\n", size, oloc);
printf("Input file: %lX bytes. Decompressed: %X bytes.\n", size, oloc);
return 0;
}

Binary file not shown.

Binary file not shown.

View File

@@ -248,7 +248,7 @@ DrawPlayerFileShared:
; Flute
LDA.l InventoryTrackingSRAM : AND.w #$0003 : BEQ +
LDA.l $7003C2 : AND.w #$00FF : CMP.w #$00FF : BNE .pseudo
LDA.l $7003C2 : AND.w #$00FF : BNE .pseudo
%fs_drawItem(7,16,FileSelectItems_flute)
BRA ++
.pseudo

View File

@@ -115,7 +115,7 @@ InitInventoryTracking: skip 2 ; PC 0x18338C \ Need to set bits here fo
InitBowTracking: skip 2 ; PC 0x18338E / boomerangs, powder/mushroom, etc
InitItemLimitCounts: skip 16 ; PC 0x183390
skip 34 ;
InitFluteBitfield: db $FF ;
InitFluteBitfield: db $00 ;
InitSpecialWeaponLevel: db $00 ;
InitItemOnB: db $00 ;
InitProgressIndicator: db $02 ; PC 0x1833C5 - Set to $80 for instant post-aga with standard

View File

@@ -34,16 +34,20 @@ RTL
; Output: 0 locked, 1 open
;--------------------------------------------------------------------------------
CheckForZelda:
LDA.l ProgressIndicator : CMP.b #$02 : !BLT + ; Skip if rain is falling
LDA.b #$01 ; pretend we have zelda anyway
RTL
+
LDA.l FollowerIndicator
LDA.l ProgressIndicator : CMP.b #$02 : !BLT + ; Skip if rain is falling
LDA.b #$01 ; pretend we have zelda anyway
RTL
+
LDA.l FollowerIndicator
RTL
;================================================================================
SetOverlayIfLamp:
JSL LampCheck
STA.b SUBDESQ ; write it directly to the overlay, this isn't a terrible idea at all
JSL LampCheck
CMP.b #$00
BEQ +
LDA.b #$01
+
STA.b SUBDESQ ; write it directly to the overlay, this isn't a terrible idea at all
RTL
;================================================================================
; Mantle Object Changes

View File

@@ -188,12 +188,12 @@ ItemBehavior:
BRA .store_inventory_tracking
.flute_inactive
LDA.b #$FF : STA.l FluteBitfield
LDA.b #$00 : STA.l FluteBitfield
LDA.l InventoryTracking : ORA.b #$02
BRA .store_inventory_tracking
.flute_active
LDA.b #$FF : STA.l FluteBitfield
LDA.b #$00 : STA.l FluteBitfield
LDA.l InventoryTracking : ORA.b #$01
BRA .store_inventory_tracking

View File

@@ -320,7 +320,7 @@ OWLightWorldOrCrossed:
OWFluteCancel:
{
lda.l FluteBitfield : beq +
lda.l FluteBitfield : cmp.b #$FF : beq +
lda.l OWFlags+1 : and.b #$01 : bne +
jsl FluteMenu_LoadTransport : rtl
+ lda.w RandoOverworldTargetEdge : bne +
@@ -332,7 +332,7 @@ OWFluteCancel2:
lda.b Joy1B_All : ora.b Joy1A_All : and.b #$c0 : bne +
jml FluteMenu_HandleSelection_NoSelection
+ inc.w SubModuleInterface
lda.l FluteBitfield : beq .cancel
lda.l FluteBitfield : cmp.b #$FF : beq .cancel
lda.l OWFlags+1 : and.b #$01 : beq +
lda.b Joy1B_All : cmp.b #$40 : bne +
.cancel

View File

@@ -1,35 +1,37 @@
SelectFirstFluteSpot:
LDA.l FluteBitfield
CMP.b #$FF
BNE +
RTL
+ LDA.b #$07
STA.w $1AF0
STA.w FluteSelection
.try_next
LDA.w $1AF0
LDA.w FluteSelection
INC A
AND.b #$07
STA.w $1AF0
STA.w FluteSelection
TAX
LDA.l FluteBitfield
AND.l $8AB7A3, X
BEQ .try_next
AND.l FluteMenuNumbers_bits, X
BNE .try_next
RTL
SelectFluteNext:
LDA.l FluteBitfield
CMP.b #$FF
BEQ InvalidBeep
.try_next
LDA.w $1AF0
LDA.w FluteSelection
INC A
AND.b #$07
STA.w $1AF0
STA.w FluteSelection
TAX
LDA.l FluteBitfield
AND.l $8AB7A3, X
BEQ .try_next
AND.l FluteMenuNumbers_bits, X
BNE .try_next
LDA.b #$20
STA.w $012F
@@ -37,18 +39,19 @@ RTL
SelectFlutePrev:
LDA.l FluteBitfield
CMP.b #$FF
BEQ InvalidBeep
.try_next
LDA.w $1AF0
LDA.w FluteSelection
DEC A
AND.b #$07
STA.w $1AF0
STA.w FluteSelection
TAX
LDA.l FluteBitfield
AND.l $8AB7A3, X
BEQ .try_next
AND.l FluteMenuNumbers_bits, X
BNE .try_next
LDA.b #$20
STA.w $012F
@@ -62,8 +65,8 @@ RTL
SetFluteSpotPalette:
XBA
LDA.l FluteBitfield
AND.l $8AB7A3, X
BEQ .disabled
AND.l FluteMenuNumbers_bits, X
BNE .disabled
.enabled
XBA
STA.b $0C
@@ -93,8 +96,9 @@ MaybeMarkFluteSpotVisited:
TXA
LSR A
TAX
LDA.l FluteBitfield
ORA.l $8AB7A3, X
LDA.l FluteMenuNumbers_bits, X
EOR.b #$FF
AND.l FluteBitfield
STA.l FluteBitfield
.done
@@ -113,33 +117,9 @@ CheckTransitionOverworld:
STA.w $040A ; what we wrote over
JML MaybeMarkFluteSpotVisited
DrawFluteIcon:
AND.w #$00FF
CMP.w #$0002
BCC .write
CheckFlute:
LDA.l FluteBitfield
AND.w #$00FF
CMP.w #$00FF
BNE .pseudo
.real
LDA.w #$0003
BRA .write
.pseudo
LDA.w #$0002
.write
STA.b $02
RTL
CheckFluteInHUD:
LDA.l $7EF33F, X
AND.w #$00FF ; what we wrote over
CPX.w #$000D
BNE .done
CMP.w #$0002
BCC .done
LDA.l FluteBitfield
AND.w #$00FF
CMP.w #$00FF
BNE .pseudo
.real
LDA.w #$0003
@@ -147,4 +127,24 @@ CheckFluteInHUD:
.pseudo
LDA.w #$0002
.done
RTS
DrawFluteIcon:
AND.w #$00FF
CMP.w #$0002
BCC +
JSR CheckFlute
+
STA.b $02
RTL
CheckFluteInHUD:
LDA.l EquipmentWRAM-1, X
AND.w #$00FF ; what we wrote over
CPX.w #$000D
BNE +
CMP.w #$0002
BCC +
JSR CheckFlute
+
RTL

View File

@@ -468,6 +468,8 @@ RoomStripes = $7E1100 ; Used for room drawing.
;
MirrorPortalPosXH = $7E1ACF ; Mirror portal position. (High byte of X coordinate)
;
FluteSelection = $7E1AF0 ; Currently selected flute spot (zero-indexed)
;
IrisPtr = $7E1B00 ; Spotlight pointers for HDMA. $1C0 bytes (?).
;
MessageSubModule = $7E1CD8 ;

View File

@@ -283,6 +283,7 @@ EntranceData_song = $82D592
SpawnPointData_room_id = $82D8D2
Overworld_CheckForSpecialOverworldTrigger_Direction = $84E879
Sprite_ShowSolicitedMessage_Direction = $85E1A3
FluteMenuNumbers_bits = $8AB7A3
WorldMap_RedXChars = $8ABF70
WorldMap_CalculateOAMCoordinates = $8AC3B1
WorldMap_HandleSpriteBlink = $8AC52E