Just Jeff Posted September 30, 2016 Share Posted September 30, 2016 Does anyone have the source code for the attached BIN and/or insight into how it works? I'd really like to use some of the music for a menu screen in my game if at all possible and if I could get permission. Even if its not possible, I'd be really curious how it works. xSqueeker Demo (2011) (Szuwarek, Factor 6) (PAL).bin Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted September 30, 2016 Author Share Posted September 30, 2016 (edited) Stepping through the code after the music starts, it just seems to make a lot of RAM adds with carry and then stores them. Then also a bunch of ROL RAM_81 which it eventually stores in AUDV0. And that's about it. Just keeps looping through. Doesn't make any sense to me. Edited September 30, 2016 by BNE Jeff Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted September 30, 2016 Share Posted September 30, 2016 (edited) Interesting code... The adds are coming from converting frequencies into digital on/off signals. There seem to be four channels simulated in parallel, the carry bits from the four 16 bit adds are collected in B1. The branch before AUDV0 is important, because only one channel can be heard when you remove it. The branch sets AUDV0 to 15 instead of 0, when B1 is 0. Probably that's done to increase the overall volume. Anyway, in the end, each channel has its own volume bit. Clever. BTW: The add #$20 before the branch boosts the base frequency. Try other values like $00 or $40 to hear the effect. Edited September 30, 2016 by Thomas Jentzsch 1 Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted October 1, 2016 Author Share Posted October 1, 2016 I downloaded DiStella and disassembled it. I'm going to see how well I can figure it out and comment it now. Squeeker Raw.asm Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 1, 2016 Share Posted October 1, 2016 I roughly did the same and tried to understand some details. Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted October 1, 2016 Author Share Posted October 1, 2016 Hmm.. tougher than I thought. Also, I guess I'm not sure how ROL works. When you ROL those RAM locations down at the bottom, what is it doing? What happens to the carry? 'Lil help? ; Initialize sound loop LF7A2: LDA #$02 STA $91 LDA #$29 STA $A0 LDA #$FA STA $A1 JMP LF7BD LF7B1: LDA #$03 STA $91 LDA #$AB STA $A0 LDA #$FA STA $A1 LF7BD: LDY #$00 STY $A2 ; Start of a sound loop LF7C1: LDA $A2 ; Initially 0 BNE LF807 ; if this is not the first trip through, then continue LDY #$00 STY $B4 ; Zero out 4 RAMs STY $B7 STY $BA STY $BD LDA ($A0),Y ; $A0 is initialized with #$29, then #$AB STA $B5 INY LDA ($A0),Y ; BEQ LF7B1 ; If zero, then go to second initialization STA $B6 INY LDA ($A0),Y STA $B8 INY LDA ($A0),Y STA $B9 INY LDA ($A0),Y STA $BB INY LDA ($A0),Y STA $BC INY LDA ($A0),Y STA $BE INY LDA ($A0),Y STA $BF LDA #$08 CLC ADC $A0 ; $A0 is initialized with #$29, then $AB STA $A0 ; then store the result BCC LF803 INC $A1 ; initialized with #$FA LF803: LDA #$40 STA $A2 LF807: LDA #$FF STA $92 LDY #$00 LDA #$01 STA $B3 LDA $B4 BNE LF835 LDA ($B5),Y TAX INY LDA ($B5),Y STA $B4 LDA $B5 CLC ADC #$02 STA $B5 BCC LF828 INC $B6 LF828: LDA LF967,X ; Load from sound table STA $B1 DEX LDA LF967,X ; Load from sound table STA $B0 LDA $B4 LF835: CMP $92 BCS LF83B STA $92 LF83B: LDY #$00 LDA #$C0 STA $AF LDA $B7 BNE LF865 LDA ($B8),Y TAX INY LDA ($B8),Y STA $B7 LDA $B8 CLC ADC #$02 STA $B8 BCC LF858 INC $B9 LF858: LDA LF967,X ; Load from sound table STA $AD DEX LDA LF967,X ; Load from sound table STA $AC LDA $B7 LF865: CMP $92 BCS LF86B STA $92 LF86B: LDY #$00 LDA #$80 STA $AB LDA $BA BNE LF895 LDA ($BB),Y TAX INY LDA ($BB),Y STA $BA LDA $BB CLC ADC #$02 STA $BB BCC LF888 INC $BC LF888: LDA LF967,X ; Load from sound table STA $A9 DEX LDA LF967,X ; Load from sound table STA $A8 LDA $BA LF895: CMP $92 BCS LF89B STA $92 LF89B: LDY #$00 LDA #$40 STA $A7 LDA $BD BNE LF8C5 LDA ($BE),Y TAX INY LDA ($BE),Y STA $BD LDA $BE CLC ADC #$02 STA $BE BCC LF8B8 INC $BF LF8B8: LDA LF967,X ; Load from sound table STA $A5 DEX LDA LF967,X ; Load from sound table STA $A4 LDA $BD LF8C5: CMP $92 BCS LF8CB STA $92 LF8CB: LDA $BD SEC SBC $92 STA $BD LDA $BA SEC SBC $92 STA $BA LDA $B7 SEC SBC $92 STA $B7 LDA $B4 SEC SBC $92 STA $B4 LDA $92 LDY #$00 STY $96 STY $97 LDY #$07 LF8F1: ASL $96 ROL $97 ASL A BCC LF904 LDA $96 ADC #$7F STA $96 LDA $97 ADC $91 ; $91 is initialized with #$02, then #$03 STA $97 LF904: DEY BPL LF8F1 LDA $A2 SEC SBC $92 STA $A2 LDY $96 LDX $97 ; Fall into loop ; Load sound from table, add to a value, then store back in RAM. Store some ; values to AUDV0 LF912: LDA #$00 ; Set VOL0 to 0 STA $81 ; Audio Volume RAM CLC LDA $A4 ; data from sound table ADC $A6 ; starts at 0 STA $A6 ; store the result LDA $A5 ; data from sound table ADC $A7 ; starts at #$40 STA $A7 ; store the result ROL $81 ; Audio Volume RAM LDA $A8 ; data from sound table ADC $AA ; starts at 0 STA $AA ; store the result LDA $A9 ; data from sound table ADC $AB ; starts at #$80 STA $AB ; store the result ROL $81 ; Audio Volume RAM LDA $AC ; data from sound table ADC $AE ; starts at 0 STA $AE ; store the result LDA $AD ; data from sound table ADC $AF ; starts at #$C0 STA $AF ; store the result ROL $81 ; Audio Volume RAM LDA $B0 ; data from sound table ADC $B2 ; starts at 0 STA $B2 ; store the result LDA $B1 ; data from sound table ADC $B3 ; starts at #$01 STA $B3 ; store the result ROL $81 ; Audio Volume RAM ADC #$20 LDA #$00 ADC $81 ; Audio Volume RAM BEQ LF95A ; Restart the Demo? LDA $81 ; Audio Volume RAM BIT $0F09 ; Test what? Why? Skip AUDV0? STA AUDV0 DEY BNE LF912 DEX ; from 151 BNE LF912 JMP LF7C1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Sound Table ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LF967: .byte $69,$00,$70,$00,$76,$00,$7D,$00,$85,$00,$8D,$00,$95,$00,$9E,$00 .byte $A7,$00,$B1,$00,$BC,$00,$C7,$00,$D3,$00,$E0,$00,$ED,$00,$FB,$00 .byte $0A,$01,$1A,$01,$2B,$01,$3C,$01,$4F,$01,$63,$01,$78,$01,$8F,$01 .byte $A7,$01,$C0,$01,$DA,$01,$F7,$01,$15,$02,$34,$02,$56,$02,$79,$02 .byte $9F,$02,$C7,$02,$F Skweeker Disassembly.asm Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 1, 2016 Share Posted October 1, 2016 The carry is shifted into $81 and bit 7 of $81 is shift into carry. Since $81 was initialized with 0 and there are only four ROLs, the carry is always clear afterwards. Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted October 2, 2016 Author Share Posted October 2, 2016 The carry is shifted into $81 and bit 7 of $81 is shift into carry. Since $81 was initialized with 0 and there are only four ROLs, the carry is always clear afterwards. Thanks! I see on the other thread that you're making great progress on this, so I'll defer to you on it I believe I butchered my commented file anyway- it assembles, but doesn't work anymore. Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 2, 2016 Share Posted October 2, 2016 (edited) I have stopped analyzing, now that I know how it works. I can give you my file, it assembles and works, but it has some little modifications too. xsqueeker_org.asm Edited October 2, 2016 by Thomas Jentzsch 1 Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted October 2, 2016 Author Share Posted October 2, 2016 Thanks! What is the significance of the data tables right after the ORG $F000 ? They look like unused graphics but when I try chopping them out and it messes up the whole thing. Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 2, 2016 Share Posted October 2, 2016 Those tables contain some graphics displayed in the first parts of the demo. The mess up results from changing all following addresses. You can set all bytes to 0, then you see the difference without messing up the code. Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted October 3, 2016 Author Share Posted October 3, 2016 Hmm.. DASM doesn't adjust the JMP and JSR addresses based on the labels that are in the ASM? Ever since I started learning this stuff, I've moved and deleted tables all the time. Could you tell me why it doesn't work here? What is the difference? Are the LFxxxs not real labels? Thanks for your patience and help! Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 3, 2016 Share Posted October 3, 2016 The labels are not the problem. But some data (e.g. immediate loads or tables) contains pointers. E.g. After LF7A2 the code loads and stores the song pointers. Unless you replace the immediate loads with labels (like in my disassembly), DASM only sees two fixed values here. But if the song data address has been changed, the song pointers will be pointing at the wrong address. And the song data itself is also just a bunch of pointers. Without labels you cannot move the data they are pointing at, too. Quote Link to comment Share on other sites More sharing options...
enthusi Posted October 3, 2016 Share Posted October 3, 2016 and if I may add for completeness, you can only safely move tables or labels in full page steps (256 bytes). Otherwise you might introduce or lose extra cycles for crossing page boundaries. Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted October 3, 2016 Author Share Posted October 3, 2016 Hmm.. It seems that I greatly overestimated DiStella's ability to make labels. So is this setting the pointer at $1F40? 'cause it doesn't look like that address exists LF151 lda #$40 ; 2 sta $96 ; 3 .lenLo lda #$1F ; 2 sta $97 ; 3 .lenHi Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 4, 2016 Share Posted October 4, 2016 Yup, this sets the pointer to $1f40 (which is identical to e.g. $ff40) for the following multiple lda ($96),y. There seems to be no table at $ff40, just a bunch of $ff. But maybe that's exactly what the code needs here. Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted October 4, 2016 Author Share Posted October 4, 2016 and if I may add for completeness, you can only safely move tables or labels in full page steps (256 bytes). Otherwise you might introduce or lose extra cycles for crossing page boundaries. Thanks.. I'll keep an eye out for that. First though, I'm going to try the labeling without chopping anything. Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted October 4, 2016 Author Share Posted October 4, 2016 Yup, this sets the pointer to $1f40 (which is identical to e.g. $ff40) for the following multiple lda ($96),y. There seems to be no table at $ff40, just a bunch of $ff. But maybe that's exactly what the code needs here. Hey I got something almost right! I guess that's mirroring? Now I see what you did here and what it means: LFD6B .byte $79,$20,$75,$10,$6B,$10,$C1,$01,$8B,$01,$93,$01 .byte $8F,$08,$8B,$02,$C1,$06,$73,$10,$77,$10,$6F,$10,$79,$08,$77,$08 .byte $77,$10,$7B,$10,$73,$10,$7D,$08,$7B,$08,$3F,$04,$57,$04,$3F,$04 .byte $57,$04,$C1,$04,$C1,$04,$C1,$04,$C1,$04,$3D,$04,$55,$04,$3D,$04 .byte $55,$04,$C1,$04,$C1,$04,$C1,$04,$35,$04 ORG $fffc .byte $EA,$F0,$EA,$F0 So I guess absent anything else, DASM will fill in empty spots with $ff? Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 4, 2016 Share Posted October 4, 2016 Yup, $ff is DASM's default filler value. Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted October 5, 2016 Author Share Posted October 5, 2016 Can you tell me what I'm doing wrong here? I can't get this to assemble. I've replaced $96 with .lenLo and I get: unresolved symbols list 0.lenLo LF12D ldy $99 ; 3 lda LF1B2,y ; 4 beq LF151 ; 2 sec ; 2 sbc #$21 ; 2 asl ; 2 tax ; 2 lda LF221,x ; 4 sta .lenLo ; 3 Replaced $96 inx ; 2 lda LF221,x ; 4 sta $97 ; 3 jsr LF16A ; 6 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 5, 2016 Share Posted October 5, 2016 And where did you define .lenLo? Note: Variables and labels which start with a . are local and only visible until the next SUBROUTINE marker. Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted October 5, 2016 Author Share Posted October 5, 2016 I thought you did it here: ; calculated PCM loop length: .lenLo = $96 .lenHi = $97 So that is only in the LF7A2 SUBROUTINE then? Is that so you can use different names for the same RAM? Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 5, 2016 Share Posted October 5, 2016 So that is only in the LF7A2 SUBROUTINE then? Is that so you can use different names for the same RAM?Yup. Quite useful if you have to use the same ZP-variable for different purposes. But you could do that without . too. The . just prevents you from using that variable accidentally somewhere else. E.g. this would work too: var1 = $96 var2 = $96 All labels are just aliases for values. BTW: You can also reuse jump labels like e.g. .loop or .skip without having to think about a new name over and over again. Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted October 6, 2016 Author Share Posted October 6, 2016 (edited) OK Thanks! Ah, so I can remove the "." and it will start working. However, I assume that since you did not do what I was attempting to do, that location must have another use and lenLo, etc. will confuse things. I recently became familiar with the following when I was integrating a 48 pixel graphic into my game which has a 2x6 digit score display. Both use a fair amount of RAM, but never at the same time. : G48 EQU pfMasks So, what is ZP? Zero Point? Edited October 6, 2016 by BNE Jeff Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted October 6, 2016 Share Posted October 6, 2016 Normally ZP means Zero Page when talking about 6502 assembler. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.