/ Published in: Other

For batari Basic, which is found at http://bataribasic.com
To use functions in bB, a=ExampleFunction(arg1,arg2)
To use functions in asm, make register a = arg1, y = arg2, and do jsr to function, and it returns value in register a.
To use functions in bB, a=ExampleFunction(arg1,arg2)
To use functions in asm, make register a = arg1, y = arg2, and do jsr to function, and it returns value in register a.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
asm ;function Abs(n) returns absolute value of n Abs bpl AbsDone sta temp1 lda #0 sec sbc temp1 AbsDone rts ;function Dist(x1,x2) returns distance from x1 to x2 Dist sty temp1 sec sbc temp1 jsr Abs rts ;function RndLow(n) returns integer less than n ;with lower results more frequent RndLow STA temp1 LDX #255 .RndLowLoop INX CPX temp1 BCC RndLowOk LDA #0 RTS RndLowOk jsr randomize STA temp3 BIT temp3 BMI .RndLowLoop txa RTS ;function RandRange(low,high) returns a random number ;between low and high, this needs to be optimized RandRange STA temp1 STY temp2 jsr randomize STA temp3 CMP #0 BEQ .RandDone .RandLoop jsr randomize STA temp3 CMP temp2 bcs .RandLoop CMP temp1 bcc .RandLoop .RandDone RTS ;subroutine AddScore adds to score the value in variable 's' ;assumes variable 't' is a frame counter ;call before every drawscreen .AddScore ldx s beq ScoreDone lda t and #3 bne ScoreDone dex bne ScoreCont lda #4 jmp SetScCol ScoreCont lda t asl asl asl asl clc adc #14 SetScCol sta scorecolor SED CLC LDA score+2 ADC #$01 STA score+2 LDA score+1 ADC #$00 STA score+1 LDA score ADC #$00 STA score CLD stx s ScoreDone rts end
Comments
