Dacobi

Members

34

Rare

10

1. Fixed point math for cc65?

It's from this YouTube tutorial https://www.youtube.com/watch?v=S12qx1DwjVk He shows how to get around using long long. I tried making my own 64bit structure, and it did work but was way to slow for my purposes.
2. Fixed point math for cc65?

I found some code that works with long int in cc65 guess its 16.16 It just has very limited range #include <stdio.h> #include <stdlib.h> #define scale 16 #define IntToFixed(x) ((x) << scale) #define FixedToInt(x) ((x) >> scale) #define TwoIntToFixed(x,y) IntToFixed(x) + IntToFixed(y)/100 #define FractionPart(x) ((x) & FractionMask) #define WholePart(x) ((x) & WholeMask) #define MUL(x,y) ((((x)>>8)*((y)>>8))>>0) #define DIV(x,y) (((x) << 8 )/ (y) << 8 ) const long FractionMask = (0xffffffff >> (32 - scale)); const long WholeMask = -1 ^ ((0xffffffff >> (32 - scale))); void fprint(long mval){ printf("%ld,%ld\n", FixedToInt(WholePart(mval)), ((FractionPart(mval)*10000))>>16); }
3. Fixed point math for cc65?

Does anyone have some fixed point code for cc65? Found this https://github.com/PetteriAimonen/libfixmath and tried porting it to cc65, but it uses a lot of 64 bit integers and don't really have the skills to fix that.
4. Low framerate when mixing two PCM streams

I just moved the screen update to a custom interrupt handler and that increased the framerate and audio processing quite a lot.
5. Low framerate when mixing two PCM streams

Yes, sorry, I already changed that a few days ago. But at the time it didn't change anything. I would like to setup a custom IRQ handler but haven't looked into doing that in C. If I disable VSYNC altogether the framerate increases a lot but then the screen is torn. Now my loop is: while(notdone){ //process audio //process input SEI() VSYNC() //update screen CLI() } My Audio loop is: VERA.audio.rate = 0; if(2nd_audio){ while(!(VERA.audio.control & 0x80)){ //while(ii<256){ VERA.audio.data = p[l] + p2[l]; //ii++; l++; if(l > 4095) {l=0;} } } else { while(!(VERA.audio.control & 0x80)){ //while(ii<256){ VERA.audio.data = p[l]; //ii++; l++; if(l > 4095) {l=0;} } } VERA.audio.rate = 64; If I uncomment ii++ there's still some slowdown.
6. Low framerate when mixing two PCM streams

I'm using cc65. Can you declare a variable as zero page in C?
7. Low framerate when mixing two PCM streams

Adding the line int i++ to the audio loop is enough to kill the framerate. Looking at the assembler code the only difference is this snippet: ldy #\$08 jsr ldaxysp ina bne L0796 inx L0796: ldy #\$07 jsr staxysp ldy #\$6A jsr ldaxysp As far as I can tell it just gets the int variable from stack, increases it and stores it again?
8. Low framerate when mixing two PCM streams

I just added -O to my build script and that seems to have fixed the problem. (edit) but then just adding audio_2nd_i++; where audio_2nd_i is an int and the problem is back.
9. Low framerate when mixing two PCM streams

This has the same result. Adder was defined as a char. I think this is most of the audio loop, but don't understand it. jsr _VSYNC ldx #\$00 lda #\$00 ldy #\$61 jsr staxysp jmp L0798 L077F: ldx #\$00 lda \$9F3B ldx #\$00 and #\$80 stx tmp1 ora tmp1 jeq L0784 jmp L0780 L0784: ldy #\$62 jsr ldaxysp sta regsave stx regsave+1 ina bne L0789 inx L0789: ldy #\$61 jsr staxysp lda regsave ldx regsave+1 ldy #\$0A lda (sp),y dey ora (sp),y jeq L078A ldy #\$05 jsr ldaxysp jsr pushax ldy #\$6C jsr ldaxysp jsr tosaddax ldy #\$00 jsr ldauidx jsr pushax ldy #\$05 jsr ldaxysp jsr pushax ldy #\$6E jsr ldaxysp jsr tosaddax ldy #\$00 jsr ldauidx jsr tosaddax ldx #\$00 sta \$9F3D ;write audio jmp L0791 L078A: ldy #\$03 jsr ldaxysp jsr pushax ldy #\$6C jsr ldaxysp jsr tosaddax ldy #\$00 jsr ldauidx sta \$9F3D ;write audio L0791: ldy #\$6A jsr ldaxysp sta regsave stx regsave+1 ina bne L0797 inx L0797: ldy #\$69 jsr staxysp lda regsave ldx regsave+1 ldy #\$6A jsr ldaxysp cmp #\$00 txa sbc #\$10 bvs L079A eor #\$80 L079A: asl a lda #\$00 ldx #\$00 rol a jeq L0798 ldx #\$00 lda #\$00 ldy #\$69 jsr staxysp L0798: ldy #\$62 jsr ldaxysp cmp #\$00 txa sbc #\$01 bvc L0783 eor #\$80 L0783: asl a lda #\$00 ldx #\$00 rol a jne L077F L0780: ldx #\$00 lda #\$00 ldy #\$5B jsr staxysp ldx #\$00 lda #\$00 ldy #\$59 jsr staxysp ldy #\$2F jsr ldaxysp ldy #\$20 jsr staxysp ldy #\$1E jsr ldaxysp sta regsave stx regsave+1 ina bne L07A4 inx L07A4: ldy #\$1D jsr staxysp lda regsave ldx regsave+1 lda #\$00 jsr _joy_read
10. Low framerate when mixing two PCM streams

Hi I have a core loop where I wait for VSYNC and then update sound and screen. The sound is 8bit mono PCM SEI(); VSYNC(); ii = 0; while(ii < 256){ if((VERA.audio.control & 0x80)){break;} ii++; if(audio_2nd){ adder = p[l] + p2[l]; VERA.audio.data = adder; } else { VERA.audio.data = p1[l];; } l++; if(l > 4095) {l=0; } } When just playing the one sample everything runs fine. But when adding two samples the game/framerate slows down a lot. How can this be when just adding two char values? The screen part of my core loop is scrolling two layers of tiles and one sprite.
11. Floating Point Library example?

I just installed Prog8 and I think it might be helpful. If nothing else it will help me learn the assembly syntax.
12. Floating Point Library example?

I'm trying to port some C code that uses a lot of floating point math, so when I came over the cc65 floatlib I thought my troubles were over. But looking at https://github.com/mrdudz/cc65-floatlib/blob/master/float.inc there seems to be some difference between which calls are used. I would just really like to have the code running before trying to do any assembler optimisations.
13. Floating Point Library example?

Thanks got it working. But it seems you are using another assembler? I could only get it to compile by adding : after definitions. (ie float5_111:) Also the programming reference said to select ROM BANK 4 but that doesn't seem to be necessary? The L1: code was something I found online. Still haven't figured out how to format a float.
14. Floating Point Library example?

That's were my assembly knowledge falls short. My current code is: LDY #\$00 L3: LDA mstring,Y CMP #0 BEQ L4 JSR \$FFD2 INY JMP L3 L4: How would I change that to an address in A.:.Y ?
15. Floating Point Library example?

As far as I can tell the only address that was different was FOUT. After changing it, my program no longer crashes, but still it doesn't print any characters. The documentation says: fout = \$fe81 ; Convert FAC to ASCIIZ string at fbuffr What is "fbuffr"? I know it's a big task. My expertise is in C/C++ But I hope that by gaining a basic understanding of the Float Lib in asm, I might get floatlib to work with x16. Currently I can compile floatlib code, but if I try to actually do something with floats, the program crashes.
×
×
• Create New...