Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;
- ; File generated by cc65 v 2.18 - Fedora 2.19-13.fc43
- ;
- .fopt compiler,"cc65 v 2.18 - Fedora 2.19-13.fc43"
- .setcpu "65C02"
- .smart on
- .autoimport on
- .case on
- .debuginfo off
- .importzp sp, sreg, regsave, regbank
- .importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4
- .macpack longbranch
- .forceimport __STARTUP__
- .import _rand
- .import _srand
- .import _MONRDKEY
- .import _MONCOUT
- .import _MONGETCHAR_NB
- .import _INIT_BUFFER
- .export _print_str
- .export _read_line
- .export _print_hex_byte
- .export _print_hex
- .export _print_num
- .export _delay
- .import _memset
- .export _gpu_put_pixel
- .export _gpu_draw_rect
- .export _gpu_fill_screen
- .export _gpu_abs
- .export _gpu_swap_coord
- .export _gpu_draw_line
- .export _gpu_draw_tri
- .export _GPUdelay
- .export _gpu_test_pattern
- .export _lcd_send_nibble
- .export _lcd_instruction
- .export _lcd_print_char
- .export _lcd_clear
- .export _lcd_newline
- .export _lcd_init
- .export _lcd_print
- .export _lcd_print_number
- .export _SIN_TABLE
- .export _via_init
- .export _vx
- .export _vy
- .export _vz
- .export _px
- .export _py
- .export _cvx
- .export _cvy
- .export _cvz
- .export _faces
- .export _face_colors
- .export _visible_faces
- .export _rotate_all
- .export _project_all
- .export _init_graphics
- .export _black_color
- .export _main
- .segment "RODATA"
- _SIN_TABLE:
- .byte $00
- .byte $02
- .byte $05
- .byte $08
- .byte $0A
- .byte $0D
- .byte $10
- .byte $12
- .byte $15
- .byte $18
- .byte $1A
- .byte $1D
- .byte $1F
- .byte $22
- .byte $25
- .byte $27
- .byte $2A
- .byte $2C
- .byte $2F
- .byte $31
- .byte $33
- .byte $36
- .byte $38
- .byte $3A
- .byte $3D
- .byte $3F
- .byte $41
- .byte $43
- .byte $45
- .byte $47
- .byte $49
- .byte $4B
- .byte $4D
- .byte $4F
- .byte $51
- .byte $53
- .byte $55
- .byte $56
- .byte $58
- .byte $59
- .byte $5B
- .byte $5C
- .byte $5E
- .byte $5F
- .byte $61
- .byte $62
- .byte $63
- .byte $64
- .byte $65
- .byte $66
- .byte $67
- .byte $68
- .byte $69
- .byte $6A
- .byte $6A
- .byte $6B
- .byte $6B
- .byte $6C
- .byte $6C
- .byte $6D
- .byte $6D
- .byte $6D
- .byte $6D
- .byte $6D
- .byte $6E
- .byte $6D
- .byte $6D
- .byte $6D
- .byte $6D
- .byte $6D
- .byte $6C
- .byte $6C
- .byte $6B
- .byte $6B
- .byte $6A
- .byte $6A
- .byte $69
- .byte $68
- .byte $67
- .byte $66
- .byte $65
- .byte $64
- .byte $63
- .byte $62
- .byte $61
- .byte $5F
- .byte $5E
- .byte $5C
- .byte $5B
- .byte $59
- .byte $58
- .byte $56
- .byte $55
- .byte $53
- .byte $51
- .byte $4F
- .byte $4D
- .byte $4B
- .byte $49
- .byte $47
- .byte $45
- .byte $43
- .byte $41
- .byte $3F
- .byte $3D
- .byte $3A
- .byte $38
- .byte $36
- .byte $33
- .byte $31
- .byte $2F
- .byte $2C
- .byte $2A
- .byte $27
- .byte $25
- .byte $22
- .byte $1F
- .byte $1D
- .byte $1A
- .byte $18
- .byte $15
- .byte $12
- .byte $10
- .byte $0D
- .byte $0A
- .byte $08
- .byte $05
- .byte $02
- .byte $00
- .byte $FE
- .byte $FB
- .byte $F8
- .byte $F6
- .byte $F3
- .byte $F0
- .byte $EE
- .byte $EB
- .byte $E8
- .byte $E6
- .byte $E3
- .byte $E1
- .byte $DE
- .byte $DB
- .byte $D9
- .byte $D6
- .byte $D4
- .byte $D1
- .byte $CF
- .byte $CD
- .byte $CA
- .byte $C8
- .byte $C6
- .byte $C3
- .byte $C1
- .byte $BF
- .byte $BD
- .byte $BB
- .byte $B9
- .byte $B7
- .byte $B5
- .byte $B3
- .byte $B1
- .byte $AF
- .byte $AD
- .byte $AB
- .byte $AA
- .byte $A8
- .byte $A7
- .byte $A5
- .byte $A4
- .byte $A2
- .byte $A1
- .byte $9F
- .byte $9E
- .byte $9D
- .byte $9C
- .byte $9B
- .byte $9A
- .byte $99
- .byte $98
- .byte $97
- .byte $96
- .byte $96
- .byte $95
- .byte $95
- .byte $94
- .byte $94
- .byte $93
- .byte $93
- .byte $93
- .byte $93
- .byte $93
- .byte $92
- .byte $93
- .byte $93
- .byte $93
- .byte $93
- .byte $93
- .byte $94
- .byte $94
- .byte $95
- .byte $95
- .byte $96
- .byte $96
- .byte $97
- .byte $98
- .byte $99
- .byte $9A
- .byte $9B
- .byte $9C
- .byte $9D
- .byte $9E
- .byte $9F
- .byte $A1
- .byte $A2
- .byte $A4
- .byte $A5
- .byte $A7
- .byte $A8
- .byte $AA
- .byte $AB
- .byte $AD
- .byte $AF
- .byte $B1
- .byte $B3
- .byte $B5
- .byte $B7
- .byte $B9
- .byte $BB
- .byte $BD
- .byte $BF
- .byte $C1
- .byte $C3
- .byte $C6
- .byte $C8
- .byte $CA
- .byte $CD
- .byte $CF
- .byte $D1
- .byte $D4
- .byte $D6
- .byte $D9
- .byte $DB
- .byte $DE
- .byte $E1
- .byte $E3
- .byte $E6
- .byte $E8
- .byte $EB
- .byte $EE
- .byte $F0
- .byte $F3
- .byte $F6
- .byte $F8
- .byte $FB
- .byte $FE
- _cvx:
- .byte $EA
- .byte $16
- .byte $16
- .byte $EA
- .byte $EA
- .byte $16
- .byte $16
- .byte $EA
- _cvy:
- .byte $EA
- .byte $EA
- .byte $16
- .byte $16
- .byte $EA
- .byte $EA
- .byte $16
- .byte $16
- _cvz:
- .byte $EA
- .byte $EA
- .byte $EA
- .byte $EA
- .byte $16
- .byte $16
- .byte $16
- .byte $16
- _faces:
- .byte $04
- .byte $05
- .byte $06
- .byte $04
- .byte $06
- .byte $07
- .byte $01
- .byte $00
- .byte $03
- .byte $01
- .byte $03
- .byte $02
- .byte $05
- .byte $01
- .byte $02
- .byte $05
- .byte $02
- .byte $06
- .byte $00
- .byte $04
- .byte $07
- .byte $00
- .byte $07
- .byte $03
- .byte $07
- .byte $06
- .byte $02
- .byte $07
- .byte $02
- .byte $03
- .byte $00
- .byte $01
- .byte $05
- .byte $00
- .byte $05
- .byte $04
- _face_colors:
- .byte $E0
- .byte $E0
- .byte $03
- .byte $03
- .byte $E3
- .byte $E3
- .byte $1C
- .byte $1C
- .byte $FC
- .byte $FC
- .byte $93
- .byte $93
- _black_color:
- .byte $00
- L0584:
- .byte $50,$52,$45,$53,$53,$20,$41,$4E,$59,$20,$4B,$45,$59,$20,$54,$4F
- .byte $20,$47,$45,$4E,$45,$52,$41,$54,$45,$20,$53,$45,$45,$44,$3A,$20
- .byte $00
- L0591:
- .byte $52,$6F,$74,$61,$74,$69,$6E,$67,$20,$43,$75,$62,$65,$00
- .segment "BSS"
- _vx:
- .res 8,$00
- _vy:
- .res 8,$00
- _vz:
- .res 8,$00
- _px:
- .res 8,$00
- _py:
- .res 8,$00
- _visible_faces:
- .res 36,$00
- ; ---------------------------------------------------------------
- ; void __near__ print_str (__near__ const unsigned char *)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _print_str: near
- .segment "CODE"
- ;
- ; void print_str(const char* s) {
- ;
- jsr pushax
- ;
- ; while (*s) {
- ;
- bra L0004
- ;
- ; if (*s == '\n') {
- ;
- L0002: ldy #$01
- lda (sp),y
- sta ptr1+1
- lda (sp)
- sta ptr1
- lda (ptr1)
- cmp #$0A
- bne L0006
- ;
- ; bios_putchar('\r');
- ;
- lda #$0D
- jsr _MONCOUT
- ;
- ; bios_putchar('\n');
- ;
- lda #$0A
- ;
- ; } else {
- ;
- bra L06C1
- ;
- ; bios_putchar(*s);
- ;
- L0006: ldy #$01
- lda (sp),y
- sta ptr1+1
- lda (sp)
- sta ptr1
- lda (ptr1)
- L06C1: jsr _MONCOUT
- ;
- ; s++;
- ;
- ldy #$01
- lda (sp),y
- tax
- lda (sp)
- ina
- bne L0010
- inx
- L0010: jsr stax0sp
- ;
- ; while (*s) {
- ;
- L0004: ldy #$01
- lda (sp),y
- sta ptr1+1
- lda (sp)
- sta ptr1
- lda (ptr1)
- bne L0002
- ;
- ; }
- ;
- jmp incsp2
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ read_line (__near__ unsigned char *, int)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _read_line: near
- .segment "BSS"
- L0012:
- .res 1,$00
- L0013:
- .res 2,$00
- .segment "CODE"
- ;
- ; void read_line(char* buffer, int max_len) {
- ;
- jsr pushax
- ;
- ; int i = 0;
- ;
- stz L0013
- stz L0013+1
- ;
- ; while (i < max_len - 1) {
- ;
- bra L0017
- ;
- ; c = bios_getchar();
- ;
- L0015: jsr _MONRDKEY
- sta L0012
- ;
- ; } while (c == 0);
- ;
- lda L0012
- beq L0015
- ;
- ; if (c == '\r' || c == '\n') {
- ;
- cmp #$0D
- beq L06C3
- cmp #$0A
- bne L0020
- ;
- ; bios_putchar('\r');
- ;
- lda #$0D
- L06C3: jsr _MONCOUT
- ;
- ; bios_putchar('\n');
- ;
- lda #$0A
- jsr _MONCOUT
- ;
- ; break; // Exit loop if Enter is pressed
- ;
- bra L0016
- ;
- ; buffer[i] = c;
- ;
- L0020: ldy #$03
- lda (sp),y
- tax
- dey
- lda (sp),y
- clc
- adc L0013
- sta ptr1
- txa
- adc L0013+1
- sta ptr1+1
- lda L0012
- sta (ptr1)
- ;
- ; i++;
- ;
- lda L0013
- ldx L0013+1
- ina
- bne L002B
- inx
- L002B: sta L0013
- stx L0013+1
- ;
- ; while (i < max_len - 1) {
- ;
- L0017: lda L0013
- ldx L0013+1
- jsr pushax
- ldy #$03
- lda (sp),y
- tax
- dey
- lda (sp),y
- sec
- sbc #$01
- bcs L0019
- dex
- L0019: jsr tosicmp
- bmi L0015
- ;
- ; buffer[i] = '\0';
- ;
- L0016: ldy #$03
- lda (sp),y
- tax
- dey
- lda (sp),y
- clc
- adc L0013
- sta ptr1
- txa
- adc L0013+1
- sta ptr1+1
- lda #$00
- sta (ptr1)
- ;
- ; }
- ;
- jmp incsp4
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ print_hex_byte (unsigned char)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _print_hex_byte: near
- .segment "RODATA"
- L0032:
- .byte $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$41,$42,$43,$44,$45,$46
- .byte $00
- .segment "BSS"
- L0031:
- .res 17,$00
- .segment "CODE"
- ;
- ; void print_hex_byte(unsigned char v) {
- ;
- jsr pusha
- ;
- ; const char hex[] = "0123456789ABCDEF";
- ;
- ldy #$10
- L0033: lda L0032,y
- sta L0031,y
- dey
- bpl L0033
- ;
- ; bios_putchar(hex[(v >> 4) & 0xF]);
- ;
- lda (sp)
- lsr a
- lsr a
- lsr a
- lsr a
- and #$0F
- sta ptr1
- lda #$00
- clc
- adc #>(L0031)
- sta ptr1+1
- ldy #<(L0031)
- lda (ptr1),y
- jsr _MONCOUT
- ;
- ; bios_putchar(hex[v & 0xF]);
- ;
- lda (sp)
- and #$0F
- sta ptr1
- lda #$00
- clc
- adc #>(L0031)
- sta ptr1+1
- ldy #<(L0031)
- lda (ptr1),y
- jsr _MONCOUT
- ;
- ; }
- ;
- jmp incsp1
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ print_hex (unsigned int)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _print_hex: near
- .segment "RODATA"
- L003E:
- .byte $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$41,$42,$43,$44,$45,$46
- .byte $00
- .segment "BSS"
- L003D:
- .res 17,$00
- .segment "CODE"
- ;
- ; void print_hex(unsigned int n) {
- ;
- jsr pushax
- ;
- ; const char hex_chars[] = "0123456789ABCDEF";
- ;
- ldy #$10
- L003F: lda L003E,y
- sta L003D,y
- dey
- bpl L003F
- ;
- ; bios_putchar('0');
- ;
- lda #$30
- jsr _MONCOUT
- ;
- ; bios_putchar('x');
- ;
- lda #$78
- jsr _MONCOUT
- ;
- ; if (n > 255) {
- ;
- ldy #$01
- lda (sp),y
- tax
- lda (sp)
- cmp #$00
- txa
- sbc #$01
- bcc L0044
- ;
- ; bios_putchar(hex_chars[(n >> 12) & 0xF]);
- ;
- ldy #$01
- lda (sp),y
- lsr a
- lsr a
- lsr a
- lsr a
- and #$0F
- sta ptr1
- lda #$00
- clc
- adc #>(L003D)
- sta ptr1+1
- ldy #<(L003D)
- lda (ptr1),y
- jsr _MONCOUT
- ;
- ; bios_putchar(hex_chars[(n >> 8) & 0xF]);
- ;
- ldy #$01
- lda (sp),y
- and #$0F
- sta ptr1
- lda #$00
- clc
- adc #>(L003D)
- sta ptr1+1
- ldy #<(L003D)
- lda (ptr1),y
- jsr _MONCOUT
- ;
- ; bios_putchar(hex_chars[(n >> 4) & 0xF]);
- ;
- L0044: ldy #$01
- lda (sp),y
- tax
- lda (sp)
- jsr shrax4
- and #$0F
- sta ptr1
- lda #$00
- clc
- adc #>(L003D)
- sta ptr1+1
- ldy #<(L003D)
- lda (ptr1),y
- jsr _MONCOUT
- ;
- ; bios_putchar(hex_chars[n & 0xF]);
- ;
- lda (sp)
- and #$0F
- sta ptr1
- lda #$00
- clc
- adc #>(L003D)
- sta ptr1+1
- ldy #<(L003D)
- lda (ptr1),y
- jsr _MONCOUT
- ;
- ; }
- ;
- jmp incsp2
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ print_num (unsigned int)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _print_num: near
- .segment "BSS"
- L0057:
- .res 10,$00
- L0058:
- .res 2,$00
- .segment "CODE"
- ;
- ; void print_num(unsigned int n) {
- ;
- jsr pushax
- ;
- ; int idx = 0;
- ;
- stz L0058
- stz L0058+1
- ;
- ; if (n == 0) {
- ;
- lda (sp)
- ldy #$01
- ora (sp),y
- bne L0061
- ;
- ; bios_putchar('0');
- ;
- lda #$30
- jsr _MONCOUT
- ;
- ; return;
- ;
- jmp incsp2
- ;
- ; buffer[idx++] = (n % 10) + '0';
- ;
- L005F: lda L0058
- ldx L0058+1
- sta regsave
- stx regsave+1
- ina
- bne L0066
- inx
- L0066: sta L0058
- stx L0058+1
- lda regsave
- clc
- adc #<(L0057)
- tay
- lda regsave+1
- adc #>(L0057)
- tax
- tya
- jsr pushax
- ldy #$05
- jsr pushwysp
- lda #$0A
- jsr tosumoda0
- clc
- adc #$30
- ldy #$00
- jsr staspidx
- ;
- ; n /= 10;
- ;
- jsr pushw0sp
- lda #$0A
- jsr tosudiva0
- jsr stax0sp
- ;
- ; while (n > 0) {
- ;
- L0061: lda (sp)
- ldy #$01
- ora (sp),y
- bne L005F
- ;
- ; while (idx > 0) {
- ;
- bra L006E
- ;
- ; bios_putchar(buffer[--idx]);
- ;
- L006C: lda L0058
- sec
- sbc #$01
- sta L0058
- bcs L0074
- dec L0058+1
- L0074: sta ptr1
- lda L0058+1
- clc
- adc #>(L0057)
- sta ptr1+1
- ldy #<(L0057)
- lda (ptr1),y
- jsr _MONCOUT
- ;
- ; while (idx > 0) {
- ;
- L006E: lda L0058
- cmp #$01
- lda L0058+1
- sbc #$00
- bvs L0070
- eor #$80
- L0070: bmi L006C
- ;
- ; }
- ;
- jmp incsp2
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ delay (unsigned int)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _delay: near
- .segment "BSS"
- L0076:
- .res 2,$00
- L0077:
- .res 2,$00
- .segment "CODE"
- ;
- ; void delay(unsigned int ms) {
- ;
- jsr pushax
- ;
- ; for (i = 0; i < ms; i++) {
- ;
- stz L0076
- stz L0076+1
- L0078: lda L0076
- cmp (sp)
- lda L0076+1
- ldy #$01
- sbc (sp),y
- bcs L0079
- ;
- ; for (j = 0; j < ITERATIONS_PER_MS; j++) {
- ;
- stz L0077
- stz L0077+1
- L0081: lda L0077+1
- cmp #$0F
- bne L0088
- lda L0077
- cmp #$A0
- L0088: bcs L007A
- lda L0077
- ldx L0077+1
- ina
- bne L008A
- inx
- L008A: sta L0077
- stx L0077+1
- bra L0081
- ;
- ; for (i = 0; i < ms; i++) {
- ;
- L007A: lda L0076
- ldx L0076+1
- ina
- bne L0080
- inx
- L0080: sta L0076
- stx L0076+1
- bra L0078
- ;
- ; }
- ;
- L0079: jmp incsp2
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ gpu_put_pixel (signed char, signed char, unsigned char)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _gpu_put_pixel: near
- .segment "BSS"
- L008C:
- .res 2,$00
- L008D:
- .res 2,$00
- .segment "CODE"
- ;
- ; void gpu_put_pixel(signed char x, signed char y, unsigned char color) {
- ;
- jsr pusha
- ;
- ; if (x < 0 || x >= GPU_WIDTH || y < 0 || y >= GPU_HEIGHT) {
- ;
- ldy #$02
- lda (sp),y
- asl a
- bcs L008B
- lda (sp),y
- sec
- sbc #$64
- bvs L0092
- eor #$80
- L0092: bmi L008B
- dey
- lda (sp),y
- asl a
- bcs L008B
- lda (sp),y
- sec
- sbc #$40
- bvs L0095
- eor #$80
- L0095: bmi L008B
- ldx #$00
- ;
- ; offset = ((unsigned short)y << 7) + (unsigned char)x;
- ;
- lda (sp),y
- cmp #$80
- bcc L009B
- dex
- L009B: jsr shlax4
- jsr shlax3
- sta ptr1
- stx ptr1+1
- iny
- lda (sp),y
- clc
- adc ptr1
- ldx ptr1+1
- bcc L06C4
- inx
- L06C4: sta L008C
- stx L008C+1
- ;
- ; vram = (unsigned char*)(unsigned long)GPU_VRAM_START;
- ;
- ldx #$20
- lda #$00
- stz L008D
- stx L008D+1
- ;
- ; vram[offset] = color;
- ;
- clc
- adc L008C
- sta ptr1
- txa
- adc L008C+1
- sta ptr1+1
- lda (sp)
- sta (ptr1)
- ;
- ; }
- ;
- L008B: jmp incsp3
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ gpu_draw_rect (signed char, signed char, signed char, signed char, unsigned char)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _gpu_draw_rect: near
- .segment "BSS"
- L00A2:
- .res 1,$00
- L00A3:
- .res 1,$00
- L00A4:
- .res 1,$00
- L00A5:
- .res 1,$00
- L00A6:
- .res 2,$00
- .segment "CODE"
- ;
- ; unsigned char color) {
- ;
- jsr pusha
- ;
- ; if (x >= GPU_WIDTH || y >= GPU_HEIGHT) return;
- ;
- ldy #$04
- lda (sp),y
- sec
- sbc #$64
- bvs L00AA
- eor #$80
- L00AA: bpl L06D2
- ;
- ; }
- ;
- jmp incsp5
- ;
- ; if (x >= GPU_WIDTH || y >= GPU_HEIGHT) return;
- ;
- L06D2: dey
- lda (sp),y
- sec
- sbc #$40
- bvs L00AC
- eor #$80
- L00AC: bpl L06D3
- ;
- ; }
- ;
- jmp incsp5
- ;
- ; if (x + w < 0 || y + h < 0) return;
- ;
- L06D3: iny
- ldx #$00
- lda (sp),y
- bpl L00B0
- dex
- L00B0: sta ptr1
- stx ptr1+1
- ldx #$00
- ldy #$02
- lda (sp),y
- bpl L00B1
- dex
- L00B1: clc
- adc ptr1
- txa
- adc ptr1+1
- tax
- cpx #$80
- bcc L06D4
- ;
- ; }
- ;
- jmp incsp5
- ;
- ; if (x + w < 0 || y + h < 0) return;
- ;
- L06D4: iny
- ldx #$00
- lda (sp),y
- bpl L00B2
- dex
- L00B2: sta ptr1
- stx ptr1+1
- ldx #$00
- ldy #$01
- lda (sp),y
- bpl L00B3
- dex
- L00B3: clc
- adc ptr1
- txa
- adc ptr1+1
- tax
- cpx #$80
- bcc L06D5
- ;
- ; }
- ;
- jmp incsp5
- ;
- ; if (x < 0) {
- ;
- L06D5: ldy #$04
- lda (sp),y
- asl a
- bcc L00B5
- ;
- ; w += x;
- ;
- lda (sp),y
- cmp #$80
- ldy #$02
- clc
- adc (sp),y
- sta (sp),y
- ;
- ; x = 0;
- ;
- lda #$00
- ldy #$04
- sta (sp),y
- ;
- ; if (y < 0) {
- ;
- L00B5: dey
- lda (sp),y
- asl a
- bcc L00BF
- ;
- ; h += y;
- ;
- lda (sp),y
- cmp #$80
- ldy #$01
- clc
- adc (sp),y
- sta (sp),y
- ;
- ; y = 0;
- ;
- lda #$00
- ldy #$03
- sta (sp),y
- ;
- ; max_x = x + w;
- ;
- L00BF: iny
- ldx #$00
- lda (sp),y
- bpl L00CB
- dex
- L00CB: sta ptr1
- stx ptr1+1
- ldx #$00
- ldy #$02
- lda (sp),y
- bpl L00CC
- dex
- L00CC: clc
- adc ptr1
- pha
- txa
- adc ptr1+1
- pla
- cmp #$80
- sta L00A3
- ;
- ; max_y = y + h;
- ;
- iny
- ldx #$00
- lda (sp),y
- bpl L00D0
- dex
- L00D0: sta ptr1
- stx ptr1+1
- ldx #$00
- ldy #$01
- lda (sp),y
- bpl L00D1
- dex
- L00D1: clc
- adc ptr1
- pha
- txa
- adc ptr1+1
- pla
- cmp #$80
- sta L00A4
- ;
- ; if (max_x > GPU_WIDTH) max_x = GPU_WIDTH;
- ;
- lda L00A3
- sec
- sbc #$65
- bvs L00D6
- eor #$80
- L00D6: bpl L06CF
- lda #$64
- sta L00A3
- ;
- ; if (max_y > GPU_HEIGHT) max_y = GPU_HEIGHT;
- ;
- L06CF: lda L00A4
- sec
- sbc #$41
- bvs L00DC
- eor #$80
- L00DC: asl a
- ldx #$00
- bcc L06D0
- lda #$40
- sta L00A4
- ;
- ; width = max_x - x;
- ;
- L06D0: lda L00A3
- bpl L00E1
- dex
- L00E1: jsr pushax
- ldy #$06
- ldx #$00
- lda (sp),y
- bpl L00E2
- dex
- L00E2: jsr tossubax
- sta L00A5
- ;
- ; ((unsigned short)y << 7) + x);
- ;
- ldy #$03
- ldx #$00
- lda (sp),y
- cmp #$80
- bcc L00E8
- dex
- L00E8: jsr shlax4
- jsr shlax3
- sta ptr1
- txa
- clc
- adc #$20
- sta ptr1+1
- ldx #$00
- iny
- lda (sp),y
- bpl L00E9
- dex
- L00E9: clc
- adc ptr1
- sta L00A6
- txa
- adc ptr1+1
- sta L00A6+1
- ;
- ; for (j = y; j < max_y; j++) {
- ;
- dey
- lda (sp),y
- sta L00A2
- L00EA: ldx #$00
- lda L00A2
- bpl L00F2
- dex
- L00F2: jsr pushax
- ldx #$00
- lda L00A4
- bpl L00F3
- dex
- L00F3: jsr tosicmp
- bpl L00EB
- ;
- ; memset(vram_row, color, width);
- ;
- lda L00A6
- ldx L00A6+1
- jsr pushax
- ldy #$02
- lda (sp),y
- jsr pusha0
- lda L00A5
- jsr _memset
- ;
- ; vram_row += GPU_STRIDE;
- ;
- lda #$80
- clc
- adc L00A6
- sta L00A6
- bcc L00FC
- inc L00A6+1
- ;
- ; for (j = y; j < max_y; j++) {
- ;
- L00FC: inc L00A2
- bra L00EA
- ;
- ; }
- ;
- L00EB: jmp incsp5
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ gpu_fill_screen (unsigned char)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _gpu_fill_screen: near
- .segment "BSS"
- L00FE:
- .res 2,$00
- .segment "CODE"
- ;
- ; void gpu_fill_screen(unsigned char color) {
- ;
- jsr pusha
- ;
- ; unsigned char* vram = (unsigned char*)GPU_VRAM_START;
- ;
- ldx #$20
- lda #$00
- stz L00FE
- stx L00FE+1
- ;
- ; memset(vram, color, GPU_STRIDE * GPU_HEIGHT);
- ;
- jsr pushax
- ldy #$02
- lda (sp),y
- jsr pusha0
- ldx #$20
- lda #$00
- jsr _memset
- ;
- ; }
- ;
- jmp incsp1
- .endproc
- ; ---------------------------------------------------------------
- ; int __near__ gpu_abs (int)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _gpu_abs: near
- .segment "CODE"
- ;
- ; int gpu_abs(int v) { return (v < 0) ? -v : v; }
- ;
- jsr pushax
- ldy #$01
- lda (sp),y
- tax
- cpx #$80
- bcc L0107
- ldy #$01
- lda (sp),y
- tax
- lda (sp)
- jsr negax
- jmp incsp2
- L0107: ldy #$01
- lda (sp),y
- tax
- lda (sp)
- jmp incsp2
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ gpu_swap_coord (__near__ signed char *, __near__ signed char *)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _gpu_swap_coord: near
- .segment "BSS"
- L010C:
- .res 1,$00
- .segment "CODE"
- ;
- ; void gpu_swap_coord(signed char* a, signed char* b) {
- ;
- jsr pushax
- ;
- ; signed char t = *a;
- ;
- ldy #$03
- lda (sp),y
- tax
- dey
- lda (sp),y
- ldy #$00
- jsr ldaidx
- sta L010C
- ;
- ; *a = *b;
- ;
- ldy #$05
- jsr pushwysp
- ldy #$03
- lda (sp),y
- tax
- dey
- lda (sp),y
- ldy #$00
- jsr ldaidx
- jsr staspidx
- ;
- ; *b = t;
- ;
- ldy #$01
- lda (sp),y
- sta ptr1+1
- lda (sp)
- sta ptr1
- lda L010C
- sta (ptr1)
- ;
- ; }
- ;
- jmp incsp4
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ gpu_draw_line (signed char, signed char, signed char, signed char, unsigned char)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _gpu_draw_line: near
- .segment "BSS"
- L0114:
- .res 1,$00
- L011A:
- .res 1,$00
- L0120:
- .res 1,$00
- L012A:
- .res 1,$00
- L0134:
- .res 2,$00
- L0138:
- .res 2,$00
- .segment "CODE"
- ;
- ; unsigned char color) {
- ;
- jsr pusha
- ;
- ; signed char dx = (signed char)gpu_abs(x1 - x0);
- ;
- ldy #$02
- ldx #$00
- lda (sp),y
- bpl L0117
- dex
- L0117: jsr pushax
- ldy #$06
- ldx #$00
- lda (sp),y
- bpl L0118
- dex
- L0118: jsr tossubax
- jsr _gpu_abs
- cmp #$80
- sta L0114
- ;
- ; signed char dy = (signed char)-gpu_abs(y1 - y0);
- ;
- ldy #$01
- ldx #$00
- lda (sp),y
- bpl L011D
- dex
- L011D: jsr pushax
- ldy #$05
- ldx #$00
- lda (sp),y
- bpl L011E
- dex
- L011E: jsr tossubax
- jsr _gpu_abs
- eor #$FF
- clc
- adc #$01
- cmp #$80
- sta L011A
- ;
- ; signed char sx = (x0 < x1) ? 1 : -1;
- ;
- ldy #$04
- ldx #$00
- lda (sp),y
- bpl L0123
- dex
- L0123: jsr pushax
- ldy #$04
- ldx #$00
- lda (sp),y
- bpl L0124
- dex
- L0124: jsr tosicmp
- bpl L0125
- lda #$01
- bra L06DB
- L0125: lda #$FF
- L06DB: cmp #$80
- sta L0120
- ;
- ; signed char sy = (y0 < y1) ? 1 : -1;
- ;
- ldy #$03
- ldx #$00
- lda (sp),y
- bpl L012D
- dex
- L012D: jsr pushax
- ldy #$03
- ldx #$00
- lda (sp),y
- bpl L012E
- dex
- L012E: jsr tosicmp
- bpl L012F
- lda #$01
- bra L06DC
- L012F: lda #$FF
- L06DC: cmp #$80
- sta L012A
- ;
- ; short err = dx + dy;
- ;
- ldx #$00
- lda L0114
- bpl L0136
- dex
- L0136: sta ptr1
- stx ptr1+1
- ldx #$00
- lda L011A
- bpl L0137
- dex
- L0137: clc
- adc ptr1
- sta L0134
- txa
- adc ptr1+1
- sta L0134+1
- ;
- ; gpu_put_pixel(x0, y0, color);
- ;
- L0139: jsr decsp2
- ldy #$06
- lda (sp),y
- ldy #$01
- sta (sp),y
- ldy #$05
- lda (sp),y
- sta (sp)
- ldy #$02
- lda (sp),y
- jsr _gpu_put_pixel
- ;
- ; if (x0 == x1 && y0 == y1) break;
- ;
- ldy #$04
- ldx #$00
- lda (sp),y
- bpl L0143
- dex
- L0143: sta ptr1
- stx ptr1+1
- ldx #$00
- ldy #$02
- lda (sp),y
- bpl L0144
- dex
- L0144: cpx ptr1+1
- bne L0141
- cmp ptr1
- bne L0141
- iny
- ldx #$00
- lda (sp),y
- bpl L0146
- dex
- L0146: sta ptr1
- stx ptr1+1
- ldx #$00
- ldy #$01
- lda (sp),y
- bpl L0147
- dex
- L0147: cpx ptr1+1
- bne L0141
- cmp ptr1
- bne L0141
- ;
- ; }
- ;
- jmp incsp5
- ;
- ; e2 = 2 * err;
- ;
- L0141: lda L0134
- ldx L0134+1
- stx tmp1
- asl a
- rol tmp1
- ldx tmp1
- sta L0138
- stx L0138+1
- ;
- ; if (e2 >= dy) {
- ;
- jsr pushax
- ldx #$00
- lda L011A
- bpl L014D
- dex
- L014D: jsr tosicmp
- bmi L0156
- ;
- ; err += dy;
- ;
- ldx #$00
- lda L011A
- cmp #$80
- bcc L06D8
- dex
- clc
- L06D8: adc L0134
- sta L0134
- txa
- adc L0134+1
- sta L0134+1
- ;
- ; x0 += sx;
- ;
- lda L0120
- cmp #$80
- ldy #$04
- clc
- adc (sp),y
- sta (sp),y
- ;
- ; if (e2 <= dx) {
- ;
- L0156: lda L0138
- ldx L0138+1
- jsr pushax
- ldx #$00
- lda L0114
- bpl L0159
- dex
- L0159: jsr tosicmp
- beq L06DA
- jpl L0139
- ;
- ; err += dx;
- ;
- L06DA: ldx #$00
- lda L0114
- cmp #$80
- bcc L06D9
- dex
- clc
- L06D9: adc L0134
- sta L0134
- txa
- adc L0134+1
- sta L0134+1
- ;
- ; y0 += sy;
- ;
- lda L012A
- cmp #$80
- ldy #$03
- clc
- adc (sp),y
- sta (sp),y
- jpl L0139
- ;
- ; while (1) {
- ;
- jmp L0139
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ gpu_draw_tri (signed char, signed char, signed char, signed char, signed char, signed char, unsigned char, unsigned char)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _gpu_draw_tri: near
- .segment "BSS"
- L0164:
- .res 2,$00
- L0165:
- .res 2,$00
- L0166:
- .res 2,$00
- L0167:
- .res 2,$00
- L0168:
- .res 1,$00
- L0169:
- .res 1,$00
- L016A:
- .res 1,$00
- L016B:
- .res 2,$00
- L016C:
- .res 2,$00
- L016D:
- .res 2,$00
- L016E:
- .res 2,$00
- .segment "CODE"
- ;
- ; unsigned char color, unsigned char fill) {
- ;
- jsr pusha
- ;
- ; if (!fill) {
- ;
- lda (sp)
- bne L016F
- ;
- ; gpu_draw_line(x0, y0, x1, y1, color);
- ;
- jsr decsp4
- ldy #$0B
- lda (sp),y
- ldy #$03
- sta (sp),y
- ldy #$0A
- lda (sp),y
- ldy #$02
- sta (sp),y
- ldy #$09
- lda (sp),y
- ldy #$01
- sta (sp),y
- ldy #$08
- lda (sp),y
- sta (sp)
- ldy #$05
- lda (sp),y
- jsr _gpu_draw_line
- ;
- ; gpu_draw_line(x1, y1, x2, y2, color);
- ;
- jsr decsp4
- ldy #$09
- lda (sp),y
- ldy #$03
- sta (sp),y
- ldy #$08
- lda (sp),y
- ldy #$02
- sta (sp),y
- ldy #$07
- lda (sp),y
- ldy #$01
- sta (sp),y
- ldy #$06
- lda (sp),y
- sta (sp)
- dey
- lda (sp),y
- jsr _gpu_draw_line
- ;
- ; gpu_draw_line(x2, y2, x0, y0, color);
- ;
- jsr decsp4
- ldy #$07
- lda (sp),y
- ldy #$03
- sta (sp),y
- ldy #$06
- lda (sp),y
- ldy #$02
- sta (sp),y
- ldy #$0B
- lda (sp),y
- ldy #$01
- sta (sp),y
- ldy #$0A
- lda (sp),y
- sta (sp)
- ldy #$05
- lda (sp),y
- jsr _gpu_draw_line
- ;
- ; return;
- ;
- jmp incsp8
- ;
- ; if (y0 > y1) {
- ;
- L016F: ldy #$06
- ldx #$00
- lda (sp),y
- bpl L0185
- dex
- L0185: jsr pushax
- ldy #$06
- ldx #$00
- lda (sp),y
- bpl L0186
- dex
- L0186: jsr tosicmp
- bmi L0183
- beq L0183
- ;
- ; gpu_swap_coord(&x0, &x1);
- ;
- lda sp
- ldx sp+1
- clc
- adc #$07
- bcc L0189
- inx
- L0189: jsr pushax
- lda sp
- ldx sp+1
- clc
- adc #$07
- bcc L018B
- inx
- L018B: jsr _gpu_swap_coord
- ;
- ; gpu_swap_coord(&y0, &y1);
- ;
- lda sp
- ldx sp+1
- clc
- adc #$06
- bcc L018E
- inx
- L018E: jsr pushax
- lda sp
- ldx sp+1
- clc
- adc #$06
- bcc L0190
- inx
- L0190: jsr _gpu_swap_coord
- ;
- ; if (y0 > y2) {
- ;
- L0183: ldy #$06
- ldx #$00
- lda (sp),y
- bpl L0193
- dex
- L0193: jsr pushax
- ldy #$04
- ldx #$00
- lda (sp),y
- bpl L0194
- dex
- L0194: jsr tosicmp
- bmi L0191
- beq L0191
- ;
- ; gpu_swap_coord(&x0, &x2);
- ;
- lda sp
- ldx sp+1
- clc
- adc #$07
- bcc L0197
- inx
- L0197: jsr pushax
- lda sp
- ldx sp+1
- clc
- adc #$05
- bcc L0199
- inx
- L0199: jsr _gpu_swap_coord
- ;
- ; gpu_swap_coord(&y0, &y2);
- ;
- lda sp
- ldx sp+1
- clc
- adc #$06
- bcc L019C
- inx
- L019C: jsr pushax
- lda sp
- ldx sp+1
- clc
- adc #$04
- bcc L019E
- inx
- L019E: jsr _gpu_swap_coord
- ;
- ; if (y1 > y2) {
- ;
- L0191: ldy #$04
- ldx #$00
- lda (sp),y
- bpl L01A1
- dex
- L01A1: jsr pushax
- ldy #$04
- ldx #$00
- lda (sp),y
- bpl L01A2
- dex
- L01A2: jsr tosicmp
- bmi L019F
- beq L019F
- ;
- ; gpu_swap_coord(&x1, &x2);
- ;
- lda sp
- ldx sp+1
- clc
- adc #$05
- bcc L01A5
- inx
- L01A5: jsr pushax
- lda sp
- ldx sp+1
- clc
- adc #$05
- bcc L01A7
- inx
- L01A7: jsr _gpu_swap_coord
- ;
- ; gpu_swap_coord(&y1, &y2);
- ;
- lda sp
- ldx sp+1
- clc
- adc #$04
- bcc L01AA
- inx
- L01AA: jsr pushax
- lda sp
- ldx sp+1
- clc
- adc #$04
- bcc L01AC
- inx
- L01AC: jsr _gpu_swap_coord
- ;
- ; if (y2 < 0 || y0 >= GPU_HEIGHT) return;
- ;
- L019F: ldy #$02
- lda (sp),y
- asl a
- bcc L06EE
- ;
- ; }
- ;
- jmp incsp8
- ;
- ; if (y2 < 0 || y0 >= GPU_HEIGHT) return;
- ;
- L06EE: ldy #$06
- lda (sp),y
- sec
- sbc #$40
- bvs L01B1
- eor #$80
- L01B1: bpl L06EF
- ;
- ; }
- ;
- jmp incsp8
- ;
- ; x_long = TO_FIXED(x0);
- ;
- L06EF: iny
- lda (sp),y
- sta L0164+1
- stz L0164
- ;
- ; dx_long = 0;
- ;
- ldx #$00
- stz L0166
- stz L0166+1
- ;
- ; if (y2 != y0) dx_long = TO_FIXED(x2 - x0) / (y2 - y0);
- ;
- ldy #$02
- lda (sp),y
- bpl L01BC
- dex
- L01BC: sta ptr1
- stx ptr1+1
- ldx #$00
- ldy #$06
- lda (sp),y
- bpl L01BD
- dex
- L01BD: cpx ptr1+1
- bne L06ED
- cmp ptr1
- beq L01BA
- L06ED: ldy #$03
- ldx #$00
- lda (sp),y
- bpl L01C2
- dex
- L01C2: jsr pushax
- ldy #$09
- ldx #$00
- lda (sp),y
- bpl L01C3
- dex
- L01C3: jsr tossubax
- tax
- lda #$00
- jsr pushax
- ldy #$04
- tax
- lda (sp),y
- bpl L01C5
- dex
- L01C5: jsr pushax
- ldy #$0A
- ldx #$00
- lda (sp),y
- bpl L01C6
- dex
- L01C6: jsr tossubax
- jsr tosdivax
- sta L0166
- stx L0166+1
- ;
- ; if (y1 > y0) {
- ;
- L01BA: ldy #$04
- ldx #$00
- lda (sp),y
- bpl L01C9
- dex
- L01C9: jsr pushax
- ldy #$08
- ldx #$00
- lda (sp),y
- bpl L01CA
- dex
- L01CA: jsr tosicmp
- jmi L01C7
- jeq L01C7
- ;
- ; x_short = TO_FIXED(x0);
- ;
- ldy #$07
- lda (sp),y
- sta L0165+1
- stz L0165
- ;
- ; dx_short = TO_FIXED(x1 - x0) / (y1 - y0);
- ;
- ldy #$05
- ldx #$00
- lda (sp),y
- bpl L01D4
- dex
- L01D4: jsr pushax
- ldy #$09
- ldx #$00
- lda (sp),y
- bpl L01D5
- dex
- L01D5: jsr tossubax
- tax
- lda #$00
- jsr pushax
- ldy #$06
- tax
- lda (sp),y
- bpl L01D7
- dex
- L01D7: jsr pushax
- ldy #$0A
- ldx #$00
- lda (sp),y
- bpl L01D8
- dex
- L01D8: jsr tossubax
- jsr tosdivax
- sta L0167
- stx L0167+1
- ;
- ; start_y = y0;
- ;
- ldy #$06
- lda (sp),y
- sta L0169
- ;
- ; end_y = y1;
- ;
- ldy #$04
- lda (sp),y
- sta L016A
- ;
- ; if (start_y < 0) {
- ;
- lda L0169
- asl a
- bcc L06E6
- ;
- ; x_long += dx_long * (-start_y);
- ;
- lda L0166
- ldx L0166+1
- jsr pushax
- ldx #$00
- lda L0169
- bpl L01E5
- dex
- L01E5: jsr negax
- jsr tosmulax
- clc
- adc L0164
- sta L0164
- txa
- adc L0164+1
- sta L0164+1
- ;
- ; x_short += dx_short * (-start_y);
- ;
- lda L0167
- ldx L0167+1
- jsr pushax
- ldx #$00
- lda L0169
- bpl L01E9
- dex
- L01E9: jsr negax
- jsr tosmulax
- clc
- adc L0165
- sta L0165
- txa
- adc L0165+1
- sta L0165+1
- ;
- ; start_y = 0;
- ;
- stz L0169
- ;
- ; if (end_y > GPU_HEIGHT) end_y = GPU_HEIGHT;
- ;
- L06E6: lda L016A
- sec
- sbc #$41
- bvs L01EF
- eor #$80
- L01EF: bpl L06E7
- lda #$40
- sta L016A
- ;
- ; for (y = start_y; y < end_y; y++) {
- ;
- L06E7: lda L0169
- sta L0168
- L01F2: ldx #$00
- lda L0168
- bpl L01FA
- dex
- L01FA: jsr pushax
- ldx #$00
- lda L016A
- bpl L01FB
- dex
- L01FB: jsr tosicmp
- jpl L022B
- ;
- ; xl = FROM_FIXED(x_long);
- ;
- ldx L0164+1
- cpx #$80
- txa
- ldx #$00
- bcc L0202
- dex
- L0202: sta L016B
- stx L016B+1
- ;
- ; xr = FROM_FIXED(x_short);
- ;
- ldx L0165+1
- cpx #$80
- txa
- ldx #$00
- bcc L0207
- dex
- L0207: sta L016C
- stx L016C+1
- ;
- ; if (xl > xr) {
- ;
- lda L016B
- ldx L016B+1
- jsr pushax
- lda L016C
- ldx L016C+1
- jsr tosicmp
- bmi L0208
- beq L0208
- ;
- ; t = xl;
- ;
- lda L016B+1
- sta L016D+1
- lda L016B
- sta L016D
- ;
- ; xl = xr;
- ;
- lda L016C+1
- sta L016B+1
- lda L016C
- sta L016B
- ;
- ; xr = t;
- ;
- lda L016D+1
- sta L016C+1
- lda L016D
- sta L016C
- ;
- ; if (xl < 0) xl = 0;
- ;
- L0208: ldx L016B+1
- cpx #$80
- bcc L0210
- stz L016B
- stz L016B+1
- ;
- ; if (xr >= GPU_WIDTH) xr = GPU_WIDTH - 1;
- ;
- L0210: lda L016C
- cmp #$64
- lda L016C+1
- sbc #$00
- bvs L0216
- eor #$80
- L0216: bpl L0214
- lda #$63
- sta L016C
- stz L016C+1
- ;
- ; if (xl <= xr) {
- ;
- L0214: lda L016B
- ldx L016B+1
- jsr pushax
- lda L016C
- ldx L016C+1
- jsr tosicmp
- beq L06E3
- bpl L0219
- ;
- ; offset = ((unsigned short)y << 7) + xl;
- ;
- L06E3: ldx #$00
- lda L0168
- cmp #$80
- bcc L021F
- dex
- L021F: jsr shlax4
- jsr shlax3
- clc
- adc L016B
- pha
- txa
- adc L016B+1
- tax
- pla
- sta L016E
- stx L016E+1
- ;
- ; memset((void*)(unsigned long)(GPU_VRAM_START + offset), color,
- ;
- pha
- txa
- clc
- adc #$20
- tax
- pla
- jsr pushax
- ldy #$03
- lda (sp),y
- jsr pusha0
- ;
- ; xr - xl + 1);
- ;
- lda L016C
- sec
- sbc L016B
- pha
- lda L016C+1
- sbc L016B+1
- tax
- pla
- ina
- bne L0225
- inx
- L0225: jsr _memset
- ;
- ; x_long += dx_long;
- ;
- L0219: lda L0166
- clc
- adc L0164
- sta L0164
- lda L0166+1
- adc L0164+1
- sta L0164+1
- ;
- ; x_short += dx_short;
- ;
- lda L0167
- clc
- adc L0165
- sta L0165
- lda L0167+1
- adc L0165+1
- sta L0165+1
- ;
- ; for (y = start_y; y < end_y; y++) {
- ;
- inc L0168
- jmp L01F2
- ;
- ; if (y0 < 0) {
- ;
- L01C7: ldy #$06
- lda (sp),y
- asl a
- bcc L022B
- ;
- ; x_long += dx_long * (-y0);
- ;
- lda L0166
- ldx L0166+1
- jsr pushax
- ldy #$08
- ldx #$00
- lda (sp),y
- bpl L0231
- dex
- L0231: jsr negax
- jsr tosmulax
- clc
- adc L0164
- sta L0164
- txa
- adc L0164+1
- sta L0164+1
- ;
- ; if (y2 > y1) {
- ;
- L022B: ldy #$02
- ldx #$00
- lda (sp),y
- bpl L0234
- dex
- L0234: jsr pushax
- ldy #$06
- ldx #$00
- lda (sp),y
- bpl L0235
- dex
- L0235: jsr tosicmp
- bpl L06F0
- ;
- ; }
- ;
- jmp incsp8
- ;
- ; if (y2 > y1) {
- ;
- L06F0: bne L06F1
- ;
- ; }
- ;
- jmp incsp8
- ;
- ; x_short = TO_FIXED(x1);
- ;
- L06F1: ldy #$05
- lda (sp),y
- sta L0165+1
- stz L0165
- ;
- ; dx_short = TO_FIXED(x2 - x1) / (y2 - y1);
- ;
- ldy #$03
- ldx #$00
- lda (sp),y
- bpl L023F
- dex
- L023F: jsr pushax
- ldy #$07
- ldx #$00
- lda (sp),y
- bpl L0240
- dex
- L0240: jsr tossubax
- tax
- lda #$00
- jsr pushax
- ldy #$04
- tax
- lda (sp),y
- bpl L0242
- dex
- L0242: jsr pushax
- ldy #$08
- ldx #$00
- lda (sp),y
- bpl L0243
- dex
- L0243: jsr tossubax
- jsr tosdivax
- sta L0167
- stx L0167+1
- ;
- ; start_y = y1;
- ;
- ldy #$04
- lda (sp),y
- sta L0169
- ;
- ; end_y = y2;
- ;
- ldy #$02
- lda (sp),y
- sta L016A
- ;
- ; if (start_y < 0) {
- ;
- lda L0169
- asl a
- bcc L024A
- ;
- ; x_long += dx_long * (0 - start_y);
- ;
- lda L0166
- ldx L0166+1
- jsr pushax
- jsr push0
- lda L0169
- bpl L0250
- ldx #$FF
- L0250: jsr tossubax
- jsr tosmulax
- clc
- adc L0164
- sta L0164
- txa
- adc L0164+1
- sta L0164+1
- ;
- ; x_short += dx_short * (0 - start_y);
- ;
- lda L0167
- ldx L0167+1
- jsr pushax
- jsr push0
- lda L0169
- bpl L0254
- ldx #$FF
- L0254: jsr tossubax
- jsr tosmulax
- clc
- adc L0165
- sta L0165
- txa
- adc L0165+1
- sta L0165+1
- ;
- ; start_y = 0;
- ;
- stz L0169
- ;
- ; if (y0 == y1 && y0 < 0) {
- ;
- L024A: ldy #$06
- ldx #$00
- lda (sp),y
- bpl L0259
- dex
- L0259: sta ptr1
- stx ptr1+1
- ldx #$00
- ldy #$04
- lda (sp),y
- bpl L025A
- dex
- L025A: cpx ptr1+1
- bne L06EA
- cmp ptr1
- bne L06EA
- ldy #$06
- lda (sp),y
- asl a
- bcc L06EA
- ;
- ; x_long += dx_long * (-y0);
- ;
- lda L0166
- ldx L0166+1
- jsr pushax
- ldy #$08
- ldx #$00
- lda (sp),y
- bpl L0261
- dex
- L0261: jsr negax
- jsr tosmulax
- clc
- adc L0164
- sta L0164
- txa
- adc L0164+1
- sta L0164+1
- ;
- ; if (end_y > GPU_HEIGHT) end_y = GPU_HEIGHT;
- ;
- L06EA: lda L016A
- sec
- sbc #$41
- bvs L0265
- eor #$80
- L0265: bpl L06EB
- lda #$40
- sta L016A
- ;
- ; for (y = start_y; y < end_y; y++) {
- ;
- L06EB: lda L0169
- sta L0168
- L0268: ldx #$00
- lda L0168
- bpl L0270
- dex
- L0270: jsr pushax
- ldx #$00
- lda L016A
- bpl L0271
- dex
- L0271: jsr tosicmp
- bmi L06F2
- ;
- ; }
- ;
- jmp incsp8
- ;
- ; xl = FROM_FIXED(x_long);
- ;
- L06F2: ldx L0164+1
- cpx #$80
- txa
- ldx #$00
- bcc L0278
- dex
- L0278: sta L016B
- stx L016B+1
- ;
- ; xr = FROM_FIXED(x_short);
- ;
- ldx L0165+1
- cpx #$80
- txa
- ldx #$00
- bcc L027D
- dex
- L027D: sta L016C
- stx L016C+1
- ;
- ; if (xl > xr) {
- ;
- lda L016B
- ldx L016B+1
- jsr pushax
- lda L016C
- ldx L016C+1
- jsr tosicmp
- bmi L027E
- beq L027E
- ;
- ; t = xl;
- ;
- lda L016B+1
- sta L016D+1
- lda L016B
- sta L016D
- ;
- ; xl = xr;
- ;
- lda L016C+1
- sta L016B+1
- lda L016C
- sta L016B
- ;
- ; xr = t;
- ;
- lda L016D+1
- sta L016C+1
- lda L016D
- sta L016C
- ;
- ; if (xl < 0) xl = 0;
- ;
- L027E: ldx L016B+1
- cpx #$80
- bcc L0286
- stz L016B
- stz L016B+1
- ;
- ; if (xr >= GPU_WIDTH) xr = GPU_WIDTH - 1;
- ;
- L0286: lda L016C
- cmp #$64
- lda L016C+1
- sbc #$00
- bvs L028C
- eor #$80
- L028C: bpl L028A
- lda #$63
- sta L016C
- stz L016C+1
- ;
- ; if (xl <= xr) {
- ;
- L028A: lda L016B
- ldx L016B+1
- jsr pushax
- lda L016C
- ldx L016C+1
- jsr tosicmp
- beq L06E4
- bpl L028F
- ;
- ; offset = ((unsigned short)y << 7) + xl;
- ;
- L06E4: ldx #$00
- lda L0168
- cmp #$80
- bcc L0295
- dex
- L0295: jsr shlax4
- jsr shlax3
- clc
- adc L016B
- pha
- txa
- adc L016B+1
- tax
- pla
- sta L016E
- stx L016E+1
- ;
- ; memset((void*)(unsigned long)(GPU_VRAM_START + offset), color,
- ;
- pha
- txa
- clc
- adc #$20
- tax
- pla
- jsr pushax
- ldy #$03
- lda (sp),y
- jsr pusha0
- ;
- ; xr - xl + 1);
- ;
- lda L016C
- sec
- sbc L016B
- pha
- lda L016C+1
- sbc L016B+1
- tax
- pla
- ina
- bne L029B
- inx
- L029B: jsr _memset
- ;
- ; x_long += dx_long;
- ;
- L028F: lda L0166
- clc
- adc L0164
- sta L0164
- lda L0166+1
- adc L0164+1
- sta L0164+1
- ;
- ; x_short += dx_short;
- ;
- lda L0167
- clc
- adc L0165
- sta L0165
- lda L0167+1
- adc L0165+1
- sta L0165+1
- ;
- ; for (y = start_y; y < end_y; y++) {
- ;
- inc L0168
- jmp L0268
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ GPUdelay (unsigned int)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _GPUdelay: near
- .segment "BSS"
- L02A1:
- .res 2,$00
- L02A2:
- .res 2,$00
- .segment "CODE"
- ;
- ; void GPUdelay(unsigned int ms) {
- ;
- jsr pushax
- ;
- ; for (i = 0; i < ms; i++) {
- ;
- stz L02A1
- stz L02A1+1
- L02A3: lda L02A1
- cmp (sp)
- lda L02A1+1
- ldy #$01
- sbc (sp),y
- bcs L02A4
- ;
- ; for (j = 0; j < GPU_ITERATIONS_PER_MS; j++) {
- ;
- stz L02A2
- stz L02A2+1
- L02AC: lda L02A2+1
- cmp #$00
- bne L02B3
- lda L02A2
- cmp #$13
- L02B3: bcs L02A5
- lda L02A2
- ldx L02A2+1
- ina
- bne L02B5
- inx
- L02B5: sta L02A2
- stx L02A2+1
- bra L02AC
- ;
- ; for (i = 0; i < ms; i++) {
- ;
- L02A5: lda L02A1
- ldx L02A1+1
- ina
- bne L02AB
- inx
- L02AB: sta L02A1
- stx L02A1+1
- bra L02A3
- ;
- ; }
- ;
- L02A4: jmp incsp2
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ gpu_test_pattern (void)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _gpu_test_pattern: near
- .segment "BSS"
- L02B7:
- .res 1,$00
- L02B8:
- .res 1,$00
- L02B9:
- .res 1,$00
- .segment "CODE"
- ;
- ; for (r = 0; r < GPU_HEIGHT; r++) {
- ;
- stz L02B7
- L06F4: lda L02B7
- cmp #$40
- bcs L02BB
- ;
- ; row_color = r * 4;
- ;
- asl a
- asl a
- sta L02B9
- ;
- ; for (c = 0; c < GPU_WIDTH; c++) {
- ;
- stz L02B8
- L06F5: lda L02B8
- cmp #$64
- bcs L06F6
- ;
- ; gpu_put_pixel(c, r, row_color + c);
- ;
- jsr decsp2
- lda L02B8
- ldy #$01
- sta (sp),y
- lda L02B7
- sta (sp)
- lda L02B9
- clc
- adc L02B8
- jsr _gpu_put_pixel
- ;
- ; for (c = 0; c < GPU_WIDTH; c++) {
- ;
- inc L02B8
- bra L06F5
- ;
- ; for (r = 0; r < GPU_HEIGHT; r++) {
- ;
- L06F6: inc L02B7
- bra L06F4
- ;
- ; }
- ;
- L02BB: rts
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ lcd_send_nibble (unsigned char, unsigned char)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _lcd_send_nibble: near
- .segment "CODE"
- ;
- ; void lcd_send_nibble(unsigned char data, unsigned char mode) {
- ;
- jsr pusha
- ;
- ; data &= 0x0F; // Ensure only low 4 bits
- ;
- ldy #$01
- lda (sp),y
- and #$0F
- sta (sp),y
- ;
- ; PORTB = data | mode | E;
- ;
- lda (sp)
- ldy #$01
- ora (sp),y
- ora #$40
- sta $6000
- ;
- ; PORTB = data | mode;
- ;
- lda (sp)
- ldy #$01
- ora (sp),y
- sta $6000
- ;
- ; }
- ;
- jmp incsp2
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ lcd_instruction (unsigned char)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _lcd_instruction: near
- .segment "CODE"
- ;
- ; void lcd_instruction(unsigned char cmd) {
- ;
- jsr pusha
- ;
- ; lcd_send_nibble(cmd >> 4, 0); // High nibble
- ;
- lda (sp)
- lsr a
- lsr a
- lsr a
- lsr a
- jsr pusha
- lda #$00
- jsr _lcd_send_nibble
- ;
- ; lcd_send_nibble(cmd, 0); // Low nibble
- ;
- lda (sp)
- jsr pusha
- lda #$00
- jsr _lcd_send_nibble
- ;
- ; }
- ;
- jmp incsp1
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ lcd_print_char (unsigned char)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _lcd_print_char: near
- .segment "CODE"
- ;
- ; void lcd_print_char(unsigned char c) {
- ;
- jsr pusha
- ;
- ; lcd_send_nibble(c >> 4, RS);
- ;
- lda (sp)
- lsr a
- lsr a
- lsr a
- lsr a
- jsr pusha
- lda #$10
- jsr _lcd_send_nibble
- ;
- ; lcd_send_nibble(c, RS);
- ;
- lda (sp)
- jsr pusha
- lda #$10
- jsr _lcd_send_nibble
- ;
- ; }
- ;
- jmp incsp1
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ lcd_clear (void)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _lcd_clear: near
- .segment "CODE"
- ;
- ; void lcd_clear(void) { lcd_instruction(0x01); }
- ;
- lda #$01
- jmp _lcd_instruction
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ lcd_newline (void)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _lcd_newline: near
- .segment "CODE"
- ;
- ; void lcd_newline(void) { lcd_print_char('\n'); }
- ;
- lda #$0A
- jmp _lcd_print_char
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ lcd_init (void)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _lcd_init: near
- .segment "CODE"
- ;
- ; DDRB = 0xFF;
- ;
- lda #$FF
- sta $6002
- ;
- ; lcd_send_nibble(0x03, 0);
- ;
- lda #$03
- jsr pusha
- lda #$00
- jsr _lcd_send_nibble
- ;
- ; lcd_send_nibble(0x03, 0);
- ;
- lda #$03
- jsr pusha
- lda #$00
- jsr _lcd_send_nibble
- ;
- ; lcd_send_nibble(0x03, 0);
- ;
- lda #$03
- jsr pusha
- lda #$00
- jsr _lcd_send_nibble
- ;
- ; lcd_send_nibble(0x02, 0);
- ;
- lda #$02
- jsr pusha
- lda #$00
- jsr _lcd_send_nibble
- ;
- ; lcd_instruction(0x28);
- ;
- lda #$28
- jsr _lcd_instruction
- ;
- ; lcd_instruction(0x0E);
- ;
- lda #$0E
- jsr _lcd_instruction
- ;
- ; lcd_instruction(0x06);
- ;
- lda #$06
- jsr _lcd_instruction
- ;
- ; lcd_clear();
- ;
- jmp _lcd_clear
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ lcd_print (__near__ const unsigned char *)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _lcd_print: near
- .segment "CODE"
- ;
- ; void lcd_print(const char* str) {
- ;
- jsr pushax
- ;
- ; while (*str) {
- ;
- bra L0307
- ;
- ; lcd_print_char(*str++);
- ;
- L0305: ldy #$01
- lda (sp),y
- tax
- lda (sp)
- sta regsave
- stx regsave+1
- ina
- bne L030B
- inx
- L030B: jsr stax0sp
- lda (regsave)
- jsr _lcd_print_char
- ;
- ; while (*str) {
- ;
- L0307: ldy #$01
- lda (sp),y
- sta ptr1+1
- lda (sp)
- sta ptr1
- lda (ptr1)
- bne L0305
- ;
- ; }
- ;
- jmp incsp2
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ lcd_print_number (unsigned int)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _lcd_print_number: near
- .segment "BSS"
- L030D:
- .res 1,$00
- L030E:
- .res 1,$00
- L030F:
- .res 1,$00
- L0310:
- .res 1,$00
- .segment "CODE"
- ;
- ; void lcd_print_number(unsigned int num) {
- ;
- jsr pushax
- ;
- ; hundreds = num / 100;
- ;
- jsr pushw0sp
- lda #$64
- jsr tosudiva0
- sta L030D
- ;
- ; remainder = num % 100;
- ;
- jsr pushw0sp
- lda #$64
- jsr tosumoda0
- sta L030E
- ;
- ; tens = remainder / 10;
- ;
- lda L030E
- jsr pusha0
- lda #$0A
- jsr tosudiva0
- sta L030F
- ;
- ; units = remainder % 10;
- ;
- lda L030E
- jsr pusha0
- lda #$0A
- jsr tosumoda0
- sta L0310
- ;
- ; if (hundreds > 0) {
- ;
- lda L030D
- beq L06F8
- ;
- ; lcd_print_char('0' + hundreds);
- ;
- clc
- adc #$30
- jsr _lcd_print_char
- ;
- ; } else if (tens > 0) {
- ;
- bra L06FF
- L06F8: lda L030F
- beq L06F9
- ;
- ; lcd_print_char('0' + tens);
- ;
- L06FF: lda L030F
- clc
- adc #$30
- jsr _lcd_print_char
- ;
- ; lcd_print_char('0' + units);
- ;
- L06F9: lda L0310
- clc
- adc #$30
- jsr _lcd_print_char
- ;
- ; }
- ;
- jmp incsp2
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ via_set_timer1 (unsigned int)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _via_set_timer1: near
- .segment "CODE"
- ;
- ; static void via_set_timer1(uint16_t count) {
- ;
- jsr pushax
- ;
- ; VIA_T1C_L = count & 0xFF;
- ;
- lda (sp)
- sta $6004
- ;
- ; VIA_T1C_H = (count >> 8) & 0xFF;
- ;
- ldy #$01
- lda (sp),y
- sta $6005
- ;
- ; }
- ;
- jmp incsp2
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ via_disable_interrupt (unsigned char)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _via_disable_interrupt: near
- .segment "CODE"
- ;
- ; static void via_disable_interrupt(uint8_t mask) {
- ;
- jsr pusha
- ;
- ; VIA_IER = mask & 0x7F; // Bit 7 = 0 (Clear)
- ;
- lda (sp)
- and #$7F
- sta $600E
- ;
- ; }
- ;
- jmp incsp1
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ via_wait_frame (void)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _via_wait_frame: near
- .segment "CODE"
- ;
- ; while (!(VIA_IFR & 0x40));
- ;
- L0700: lda $600D
- and #$40
- beq L0700
- ;
- ; VIA_IFR = 0x40;
- ;
- lda #$40
- sta $600D
- ;
- ; }
- ;
- rts
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ via_init (void)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _via_init: near
- .segment "CODE"
- ;
- ; via_disable_interrupt(0x7F);
- ;
- lda #$7F
- jsr _via_disable_interrupt
- ;
- ; VIA_ACR = 0x40;
- ;
- lda #$40
- sta $600B
- ;
- ; via_set_timer1(VIA_T1_COUNT);
- ;
- ldx #$82
- lda #$35
- jsr _via_set_timer1
- ;
- ; asm("cli");
- ;
- cli
- ;
- ; }
- ;
- rts
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ rotate_all (unsigned char, unsigned char, unsigned char)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _rotate_all: near
- .segment "BSS"
- L04B1:
- .res 2,$00
- L04B2:
- .res 2,$00
- L04B3:
- .res 2,$00
- L04B4:
- .res 2,$00
- L04B5:
- .res 2,$00
- L04B6:
- .res 2,$00
- L04B7:
- .res 2,$00
- L04BE:
- .res 2,$00
- L04C6:
- .res 2,$00
- L04CD:
- .res 2,$00
- L04D5:
- .res 2,$00
- L04DC:
- .res 2,$00
- .segment "CODE"
- ;
- ; void rotate_all(unsigned char ax, unsigned char ay, unsigned char az) {
- ;
- jsr pusha
- ;
- ; register unsigned char i;
- ;
- lda regbank+5
- jsr pusha
- ;
- ; int sin_x = ISIN(ax), cos_x = ICOS(ax);
- ;
- lda #<(_SIN_TABLE)
- ldx #>(_SIN_TABLE)
- ldy #$03
- clc
- adc (sp),y
- bcc L04BC
- inx
- L04BC: ldy #$00
- jsr ldaidx
- ldx #$00
- cmp #$80
- bcc L04BD
- dex
- L04BD: sta L04B7
- stx L04B7+1
- ldy #$03
- lda (sp),y
- clc
- adc #$40
- clc
- adc #<(_SIN_TABLE)
- tay
- lda #$00
- adc #>(_SIN_TABLE)
- tax
- tya
- ldy #$00
- jsr ldaidx
- ldx #$00
- cmp #$80
- bcc L04C5
- dex
- L04C5: sta L04BE
- stx L04BE+1
- ;
- ; int sin_y = ISIN(ay), cos_y = ICOS(ay);
- ;
- lda #<(_SIN_TABLE)
- ldx #>(_SIN_TABLE)
- ldy #$02
- clc
- adc (sp),y
- bcc L04CB
- inx
- L04CB: ldy #$00
- jsr ldaidx
- ldx #$00
- cmp #$80
- bcc L04CC
- dex
- L04CC: sta L04C6
- stx L04C6+1
- ldy #$02
- lda (sp),y
- clc
- adc #$40
- clc
- adc #<(_SIN_TABLE)
- tay
- lda #$00
- adc #>(_SIN_TABLE)
- tax
- tya
- ldy #$00
- jsr ldaidx
- ldx #$00
- cmp #$80
- bcc L04D4
- dex
- L04D4: sta L04CD
- stx L04CD+1
- ;
- ; int sin_z = ISIN(az), cos_z = ICOS(az);
- ;
- lda #<(_SIN_TABLE)
- ldx #>(_SIN_TABLE)
- iny
- clc
- adc (sp),y
- bcc L04DA
- inx
- L04DA: dey
- jsr ldaidx
- ldx #$00
- cmp #$80
- bcc L04DB
- dex
- L04DB: sta L04D5
- stx L04D5+1
- iny
- lda (sp),y
- clc
- adc #$40
- clc
- adc #<(_SIN_TABLE)
- tay
- lda #$00
- adc #>(_SIN_TABLE)
- tax
- tya
- ldy #$00
- jsr ldaidx
- ldx #$00
- cmp #$80
- bcc L04E3
- dex
- L04E3: sta L04DC
- stx L04DC+1
- ;
- ; for (i = 0; i < 8; ++i) {
- ;
- stz regbank+5
- L0701: lda regbank+5
- cmp #$08
- jcs L0707
- ;
- ; x = cvx[i];
- ;
- lda #<(_cvx)
- ldx #>(_cvx)
- clc
- adc regbank+5
- bcc L0702
- inx
- L0702: jsr ldaidx
- ldx #$00
- cmp #$80
- bcc L04F0
- dex
- L04F0: sta L04B1
- stx L04B1+1
- ;
- ; y = cvy[i];
- ;
- lda #<(_cvy)
- ldx #>(_cvy)
- clc
- adc regbank+5
- bcc L0703
- inx
- L0703: jsr ldaidx
- ldx #$00
- cmp #$80
- bcc L04F5
- dex
- L04F5: sta L04B2
- stx L04B2+1
- ;
- ; z = cvz[i];
- ;
- lda #<(_cvz)
- ldx #>(_cvz)
- clc
- adc regbank+5
- bcc L0704
- inx
- L0704: jsr ldaidx
- ldx #$00
- cmp #$80
- bcc L04FA
- dex
- L04FA: sta L04B3
- stx L04B3+1
- ;
- ; ty = (y * cos_x - z * sin_x) >> 7;
- ;
- lda L04B2
- ldx L04B2+1
- jsr pushax
- lda L04BE
- ldx L04BE+1
- jsr tosmulax
- jsr pushax
- lda L04B3
- ldx L04B3+1
- jsr pushax
- lda L04B7
- ldx L04B7+1
- jsr tosmulax
- jsr tossubax
- jsr asrax4
- jsr asrax3
- sta L04B5
- stx L04B5+1
- ;
- ; tz = (y * sin_x + z * cos_x) >> 7;
- ;
- lda L04B2
- ldx L04B2+1
- jsr pushax
- lda L04B7
- ldx L04B7+1
- jsr tosmulax
- jsr pushax
- lda L04B3
- ldx L04B3+1
- jsr pushax
- lda L04BE
- ldx L04BE+1
- jsr tosmulax
- jsr tosaddax
- jsr asrax4
- jsr asrax3
- sta L04B6
- stx L04B6+1
- ;
- ; y = ty;
- ;
- lda L04B5+1
- sta L04B2+1
- lda L04B5
- sta L04B2
- ;
- ; z = tz;
- ;
- lda L04B6+1
- sta L04B3+1
- lda L04B6
- sta L04B3
- ;
- ; tx = (x * cos_y + z * sin_y) >> 7;
- ;
- lda L04B1
- ldx L04B1+1
- jsr pushax
- lda L04CD
- ldx L04CD+1
- jsr tosmulax
- jsr pushax
- lda L04B3
- ldx L04B3+1
- jsr pushax
- lda L04C6
- ldx L04C6+1
- jsr tosmulax
- jsr tosaddax
- jsr asrax4
- jsr asrax3
- sta L04B4
- stx L04B4+1
- ;
- ; tz = (-x * sin_y + z * cos_y) >> 7;
- ;
- lda L04B1
- ldx L04B1+1
- jsr negax
- jsr pushax
- lda L04C6
- ldx L04C6+1
- jsr tosmulax
- jsr pushax
- lda L04B3
- ldx L04B3+1
- jsr pushax
- lda L04CD
- ldx L04CD+1
- jsr tosmulax
- jsr tosaddax
- jsr asrax4
- jsr asrax3
- sta L04B6
- stx L04B6+1
- ;
- ; x = tx;
- ;
- lda L04B4+1
- sta L04B1+1
- lda L04B4
- sta L04B1
- ;
- ; z = tz;
- ;
- lda L04B6+1
- sta L04B3+1
- lda L04B6
- sta L04B3
- ;
- ; tx = (x * cos_z - y * sin_z) >> 7;
- ;
- lda L04B1
- ldx L04B1+1
- jsr pushax
- lda L04DC
- ldx L04DC+1
- jsr tosmulax
- jsr pushax
- lda L04B2
- ldx L04B2+1
- jsr pushax
- lda L04D5
- ldx L04D5+1
- jsr tosmulax
- jsr tossubax
- jsr asrax4
- jsr asrax3
- sta L04B4
- stx L04B4+1
- ;
- ; ty = (x * sin_z + y * cos_z) >> 7;
- ;
- lda L04B1
- ldx L04B1+1
- jsr pushax
- lda L04D5
- ldx L04D5+1
- jsr tosmulax
- jsr pushax
- lda L04B2
- ldx L04B2+1
- jsr pushax
- lda L04DC
- ldx L04DC+1
- jsr tosmulax
- jsr tosaddax
- jsr asrax4
- jsr asrax3
- sta L04B5
- stx L04B5+1
- ;
- ; vx[i] = tx;
- ;
- lda #<(_vx)
- ldx #>(_vx)
- clc
- adc regbank+5
- bcc L0517
- inx
- L0517: sta ptr1
- stx ptr1+1
- lda L04B4
- ldy #$00
- sta (ptr1)
- ;
- ; vy[i] = ty;
- ;
- lda #<(_vy)
- ldx #>(_vy)
- clc
- adc regbank+5
- bcc L051C
- inx
- L051C: sta ptr1
- stx ptr1+1
- lda L04B5
- sta (ptr1)
- ;
- ; vz[i] = z;
- ;
- lda #<(_vz)
- ldx #>(_vz)
- clc
- adc regbank+5
- bcc L0521
- inx
- L0521: sta ptr1
- stx ptr1+1
- lda L04B3
- sta (ptr1)
- ;
- ; for (i = 0; i < 8; ++i) {
- ;
- inc regbank+5
- jmp L0701
- ;
- ; }
- ;
- L0707: lda (sp)
- sta regbank+5
- jmp incsp4
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ project_all (void)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _project_all: near
- .segment "BSS"
- L0525:
- .res 1,$00
- L0527:
- .res 1,$00
- L0529:
- .res 2,$00
- L052A:
- .res 2,$00
- .segment "CODE"
- ;
- ; register unsigned char i;
- ;
- lda regbank+5
- jsr pusha
- ;
- ; const signed char distance = 80;
- ;
- lda #$50
- sta L0525
- ;
- ; const signed char factor = 60;
- ;
- lda #$3C
- sta L0527
- ;
- ; for (i = 0; i < 8; ++i) {
- ;
- stz regbank+5
- L0708: lda regbank+5
- cmp #$08
- jcs L052C
- ;
- ; z_shifted = vz[i] + distance;
- ;
- lda #<(_vz)
- ldx #>(_vz)
- clc
- adc regbank+5
- bcc L0536
- inx
- L0536: ldy #$00
- jsr ldaidx
- sta ptr1
- stx ptr1+1
- ldx #$00
- lda L0525
- bpl L0537
- dex
- L0537: clc
- adc ptr1
- pha
- txa
- adc ptr1+1
- tax
- pla
- sta L0529
- stx L0529+1
- ;
- ; if (z_shifted < 10) z_shifted = 10;
- ;
- cmp #$0A
- txa
- sbc #$00
- bvc L053A
- eor #$80
- L053A: bpl L0538
- lda #$0A
- sta L0529
- stz L0529+1
- ;
- ; factor_precalc = (int)vx[i] * factor;
- ;
- L0538: lda #<(_vx)
- ldx #>(_vx)
- clc
- adc regbank+5
- bcc L0709
- inx
- L0709: jsr ldaidx
- ldx #$00
- cmp #$80
- bcc L0541
- dex
- L0541: jsr pushax
- ldx #$00
- lda L0527
- bpl L0542
- dex
- L0542: jsr tosmulax
- sta L052A
- stx L052A+1
- ;
- ; px[i] = (signed char)((factor_precalc / z_shifted) + (GPU_WIDTH / 2));
- ;
- lda #<(_px)
- ldx #>(_px)
- clc
- adc regbank+5
- bcc L0545
- inx
- L0545: jsr pushax
- lda L052A
- ldx L052A+1
- jsr pushax
- lda L0529
- ldx L0529+1
- jsr tosdivax
- clc
- adc #$32
- cmp #$80
- ldy #$00
- jsr staspidx
- ;
- ; factor_precalc = (int)vy[i] * factor;
- ;
- lda #<(_vy)
- ldx #>(_vy)
- clc
- adc regbank+5
- bcc L054F
- inx
- L054F: ldy #$00
- jsr ldaidx
- ldx #$00
- cmp #$80
- bcc L0550
- dex
- L0550: jsr pushax
- ldx #$00
- lda L0527
- bpl L0551
- dex
- L0551: jsr tosmulax
- sta L052A
- stx L052A+1
- ;
- ; py[i] = (signed char)((GPU_HEIGHT / 2) - (factor_precalc / z_shifted));
- ;
- lda #<(_py)
- ldx #>(_py)
- clc
- adc regbank+5
- bcc L0554
- inx
- L0554: jsr pushax
- lda #$20
- jsr pusha0
- lda L052A
- ldx L052A+1
- jsr pushax
- lda L0529
- ldx L0529+1
- jsr tosdivax
- jsr tossubax
- cmp #$80
- ldy #$00
- jsr staspidx
- ;
- ; for (i = 0; i < 8; ++i) {
- ;
- inc regbank+5
- jmp L0708
- ;
- ; }
- ;
- L052C: lda (sp)
- sta regbank+5
- jmp incsp1
- .endproc
- ; ---------------------------------------------------------------
- ; void __near__ init_graphics (void)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _init_graphics: near
- .segment "CODE"
- ;
- ; INIT_BUFFER();
- ;
- jsr _INIT_BUFFER
- ;
- ; lcd_init();
- ;
- jsr _lcd_init
- ;
- ; gpu_fill_screen(0x00);
- ;
- lda #$00
- jmp _gpu_fill_screen
- .endproc
- ; ---------------------------------------------------------------
- ; int __near__ main (void)
- ; ---------------------------------------------------------------
- .segment "CODE"
- .proc _main: near
- .segment "BSS"
- L0561:
- .res 1,$00
- L0562:
- .res 1,$00
- L0563:
- .res 1,$00
- L0564:
- .res 1,$00
- L0565:
- .res 1,$00
- L0566:
- .res 1,$00
- L0567:
- .res 1,$00
- L0568:
- .res 1,$00
- L0569:
- .res 1,$00
- L056A:
- .res 1,$00
- L056B:
- .res 1,$00
- L056C:
- .res 2,$00
- L056D:
- .res 2,$00
- L056E:
- .res 2,$00
- L056F:
- .res 2,$00
- L0570:
- .res 4,$00
- L0571:
- .res 3,$00
- L0572:
- .res 2,$00
- L0573:
- .res 1,$00
- L0574:
- .res 1,$00
- L0575:
- .res 1,$00
- L0576:
- .res 1,$00
- L0577:
- .res 1,$00
- L0579:
- .res 1,$00
- L057B:
- .res 1,$00
- L057D:
- .res 1,$00
- L057F:
- .res 2,$00
- .segment "CODE"
- ;
- ; register unsigned char i;
- ;
- lda regbank+5
- jsr pusha
- ;
- ; signed char clear_min_x = 0, clear_max_x = 0;
- ;
- stz L0577
- stz L0579
- ;
- ; signed char clear_min_y = 0, clear_max_y = 0;
- ;
- stz L057B
- stz L057D
- ;
- ; unsigned int seed = 0;
- ;
- stz L057F
- stz L057F+1
- ;
- ; init_graphics();
- ;
- jsr _init_graphics
- ;
- ; via_init();
- ;
- jsr _via_init
- ;
- ; print_str("PRESS ANY KEY TO GENERATE SEED: ");
- ;
- lda #<(L0584)
- ldx #>(L0584)
- jsr _print_str
- ;
- ; while (bios_getchar_nb() == 0) {
- ;
- bra L0588
- ;
- ; seed++;
- ;
- L0586: lda L057F
- ldx L057F+1
- ina
- bne L058B
- inx
- L058B: sta L057F
- stx L057F+1
- ;
- ; while (bios_getchar_nb() == 0) {
- ;
- L0588: jsr _MONGETCHAR_NB
- cmp #$00
- beq L0586
- ;
- ; srand(seed);
- ;
- lda L057F
- ldx L057F+1
- jsr _srand
- ;
- ; gpu_fill_screen(0x00);
- ;
- lda #$00
- jsr _gpu_fill_screen
- ;
- ; lcd_print("Rotating Cube");
- ;
- lda #<(L0591)
- ldx #>(L0591)
- jsr _lcd_print
- ;
- ; ang_x = (unsigned char)(rand());
- ;
- jsr _rand
- sta L0561
- ;
- ; ang_y = (unsigned char)(rand());
- ;
- jsr _rand
- sta L0562
- ;
- ; ang_z = (unsigned char)(rand());
- ;
- jsr _rand
- sta L0563
- ;
- ; speed_x = (char)((rand() % 8) + 1);
- ;
- jsr _rand
- jsr pushax
- ldx #$00
- lda #$08
- jsr tosmoda0
- ina
- sta L0564
- ;
- ; if (rand() & 1) speed_x = -speed_x;
- ;
- jsr _rand
- and #$01
- beq L05A1
- lda L0564
- eor #$FF
- clc
- adc #$01
- sta L0564
- ;
- ; speed_y = (char)((rand() % 8) + 1);
- ;
- L05A1: jsr _rand
- jsr pushax
- ldx #$00
- lda #$08
- jsr tosmoda0
- ina
- sta L0565
- ;
- ; if (rand() & 1) speed_y = -speed_y;
- ;
- jsr _rand
- and #$01
- beq L05AA
- lda L0565
- eor #$FF
- clc
- adc #$01
- sta L0565
- ;
- ; speed_z = (char)((rand() % 8) + 1);
- ;
- L05AA: jsr _rand
- jsr pushax
- ldx #$00
- lda #$08
- jsr tosmoda0
- ina
- sta L0566
- ;
- ; if (rand() & 1) speed_z = -speed_z;
- ;
- jsr _rand
- and #$01
- beq L05B7
- lda L0566
- eor #$FF
- clc
- adc #$01
- sta L0566
- ;
- ; if (clear_max_x >= clear_min_x && clear_max_y >= clear_min_y) {
- ;
- L05B7: ldx #$00
- lda L0579
- bpl L05BD
- dex
- L05BD: jsr pushax
- ldx #$00
- lda L0577
- bpl L05BE
- dex
- L05BE: jsr tosicmp
- bmi L070C
- ldx #$00
- lda L057D
- bpl L05C0
- dex
- L05C0: jsr pushax
- ldx #$00
- lda L057B
- bpl L05C1
- dex
- L05C1: jsr tosicmp
- bmi L070C
- ;
- ; gpu_draw_rect(clear_min_x, clear_min_y,
- ;
- jsr decsp4
- lda L0577
- ldy #$03
- sta (sp),y
- lda L057B
- dey
- sta (sp),y
- ;
- ; clear_max_x - clear_min_x + 1,
- ;
- ldx #$00
- lda L0579
- bpl L05C7
- dex
- L05C7: jsr pushax
- ldx #$00
- lda L0577
- bpl L05C8
- dex
- L05C8: jsr tossubax
- ina
- cmp #$80
- ldy #$01
- sta (sp),y
- ;
- ; clear_max_y - clear_min_y + 1,
- ;
- ldx #$00
- lda L057D
- bpl L05CC
- dex
- L05CC: jsr pushax
- ldx #$00
- lda L057B
- bpl L05CD
- dex
- L05CD: jsr tossubax
- ina
- cmp #$80
- sta (sp)
- ;
- ; black_color);
- ;
- lda _black_color
- jsr _gpu_draw_rect
- ;
- ; ang_x += speed_x;
- ;
- L070C: lda L0564
- clc
- adc L0561
- sta L0561
- ;
- ; ang_y += speed_y;
- ;
- lda L0565
- clc
- adc L0562
- sta L0562
- ;
- ; ang_z += speed_z;
- ;
- lda L0566
- clc
- adc L0563
- sta L0563
- ;
- ; rotate_all(ang_x, ang_y, ang_z);
- ;
- jsr decsp2
- lda L0561
- ldy #$01
- sta (sp),y
- lda L0562
- sta (sp)
- lda L0563
- jsr _rotate_all
- ;
- ; project_all();
- ;
- jsr _project_all
- ;
- ; min_x = 127;
- ;
- lda #$7F
- sta L0573
- ;
- ; max_x = -128;
- ;
- ina
- sta L0574
- ;
- ; min_y = 127;
- ;
- dea
- sta L0575
- ;
- ; max_y = -128;
- ;
- ina
- sta L0576
- ;
- ; for (i = 0; i < 8; ++i) {
- ;
- stz regbank+5
- L070D: lda regbank+5
- cmp #$08
- jcs L070E
- ;
- ; if (px[i] < min_x) min_x = px[i];
- ;
- lda #<(_px)
- ldx #>(_px)
- clc
- adc regbank+5
- bcc L05EF
- inx
- L05EF: ldy #$00
- jsr ldaidx
- jsr pushax
- ldx #$00
- lda L0573
- bpl L05F0
- dex
- L05F0: jsr tosicmp
- bpl L05EC
- lda #<(_px)
- ldx #>(_px)
- clc
- adc regbank+5
- bcc L05F4
- inx
- L05F4: ldy #$00
- jsr ldaidx
- sta L0573
- ;
- ; if (px[i] > max_x) max_x = px[i];
- ;
- L05EC: lda #<(_px)
- ldx #>(_px)
- clc
- adc regbank+5
- bcc L05F8
- inx
- L05F8: ldy #$00
- jsr ldaidx
- jsr pushax
- ldx #$00
- lda L0574
- bpl L05F9
- dex
- L05F9: jsr tosicmp
- bmi L05F5
- beq L05F5
- lda #<(_px)
- ldx #>(_px)
- clc
- adc regbank+5
- bcc L05FD
- inx
- L05FD: ldy #$00
- jsr ldaidx
- sta L0574
- ;
- ; if (py[i] < min_y) min_y = py[i];
- ;
- L05F5: lda #<(_py)
- ldx #>(_py)
- clc
- adc regbank+5
- bcc L0601
- inx
- L0601: ldy #$00
- jsr ldaidx
- jsr pushax
- ldx #$00
- lda L0575
- bpl L0602
- dex
- L0602: jsr tosicmp
- bpl L05FE
- lda #<(_py)
- ldx #>(_py)
- clc
- adc regbank+5
- bcc L0606
- inx
- L0606: ldy #$00
- jsr ldaidx
- sta L0575
- ;
- ; if (py[i] > max_y) max_y = py[i];
- ;
- L05FE: lda #<(_py)
- ldx #>(_py)
- clc
- adc regbank+5
- bcc L060A
- inx
- L060A: ldy #$00
- jsr ldaidx
- jsr pushax
- ldx #$00
- lda L0576
- bpl L060B
- dex
- L060B: jsr tosicmp
- bmi L05E6
- beq L05E6
- lda #<(_py)
- ldx #>(_py)
- clc
- adc regbank+5
- bcc L060F
- inx
- L060F: ldy #$00
- jsr ldaidx
- sta L0576
- ;
- ; for (i = 0; i < 8; ++i) {
- ;
- L05E6: inc regbank+5
- jmp L070D
- ;
- ; if (min_x < 0) min_x = 0;
- ;
- L070E: lda L0573
- asl a
- bcc L070F
- stz L0573
- ;
- ; if (max_x >= GPU_WIDTH) max_x = GPU_WIDTH - 1;
- ;
- L070F: lda L0574
- sec
- sbc #$64
- bvs L0618
- eor #$80
- L0618: bpl L0710
- lda #$63
- sta L0574
- ;
- ; if (min_y < 0) min_y = 0;
- ;
- L0710: lda L0575
- asl a
- bcc L0711
- stz L0575
- ;
- ; if (max_y >= GPU_HEIGHT) max_y = GPU_HEIGHT - 1;
- ;
- L0711: lda L0576
- sec
- sbc #$40
- bvs L0623
- eor #$80
- L0623: bpl L0712
- lda #$3F
- sta L0576
- ;
- ; clear_min_x = min_x;
- ;
- L0712: lda L0573
- sta L0577
- ;
- ; clear_max_x = max_x;
- ;
- lda L0574
- sta L0579
- ;
- ; clear_min_y = min_y;
- ;
- lda L0575
- sta L057B
- ;
- ; clear_max_y = max_y;
- ;
- lda L0576
- sta L057D
- ;
- ; count = 0;
- ;
- stz L056B
- ;
- ; for (i = 0; i < 12; ++i) {
- ;
- stz regbank+5
- L0713: lda regbank+5
- cmp #$0C
- jcs L0714
- ;
- ; p1 = faces[i][0];
- ;
- ldx #$00
- lda regbank+5
- jsr mulax3
- sta ptr1
- txa
- clc
- adc #>(_faces)
- sta ptr1+1
- ldy #<(_faces)
- lda (ptr1),y
- sta L0568
- ;
- ; p2 = faces[i][1];
- ;
- ldx #$00
- lda regbank+5
- jsr mulax3
- clc
- adc #<(_faces)
- sta ptr1
- txa
- adc #>(_faces)
- sta ptr1+1
- ldy #$01
- lda (ptr1),y
- sta L0569
- ;
- ; p3 = faces[i][2];
- ;
- ldx #$00
- lda regbank+5
- jsr mulax3
- clc
- adc #<(_faces)
- sta ptr1
- txa
- adc #>(_faces)
- sta ptr1+1
- iny
- lda (ptr1),y
- sta L056A
- ;
- ; v1x = px[p2] - px[p1];
- ;
- lda #<(_px)
- ldx #>(_px)
- clc
- adc L0569
- bcc L064B
- inx
- L064B: ldy #$00
- jsr ldaidx
- jsr pushax
- lda #<(_px)
- ldx #>(_px)
- clc
- adc L0568
- bcc L064D
- inx
- L064D: ldy #$00
- jsr ldaidx
- jsr tossubax
- sta L056C
- stx L056C+1
- ;
- ; v1y = py[p2] - py[p1];
- ;
- lda #<(_py)
- ldx #>(_py)
- clc
- adc L0569
- bcc L0651
- inx
- L0651: ldy #$00
- jsr ldaidx
- jsr pushax
- lda #<(_py)
- ldx #>(_py)
- clc
- adc L0568
- bcc L0653
- inx
- L0653: ldy #$00
- jsr ldaidx
- jsr tossubax
- sta L056D
- stx L056D+1
- ;
- ; v2x = px[p3] - px[p1];
- ;
- lda #<(_px)
- ldx #>(_px)
- clc
- adc L056A
- bcc L0657
- inx
- L0657: ldy #$00
- jsr ldaidx
- jsr pushax
- lda #<(_px)
- ldx #>(_px)
- clc
- adc L0568
- bcc L0659
- inx
- L0659: ldy #$00
- jsr ldaidx
- jsr tossubax
- sta L056E
- stx L056E+1
- ;
- ; v2y = py[p3] - py[p1];
- ;
- lda #<(_py)
- ldx #>(_py)
- clc
- adc L056A
- bcc L065D
- inx
- L065D: ldy #$00
- jsr ldaidx
- jsr pushax
- lda #<(_py)
- ldx #>(_py)
- clc
- adc L0568
- bcc L065F
- inx
- L065F: ldy #$00
- jsr ldaidx
- jsr tossubax
- sta L056F
- stx L056F+1
- ;
- ; cross = (long)v1x * v2y - (long)v1y * v2x;
- ;
- lda L056C
- ldx L056C+1
- jsr axlong
- jsr pusheax
- lda L056F
- ldx L056F+1
- jsr axlong
- jsr tosmuleax
- jsr pusheax
- lda L056D
- ldx L056D+1
- jsr axlong
- jsr pusheax
- lda L056E
- ldx L056E+1
- jsr axlong
- jsr tosmuleax
- jsr tossubeax
- sta L0570
- stx L0570+1
- ldy sreg
- sty L0570+2
- ldy sreg+1
- sty L0570+3
- ;
- ; if (cross >= 0) {
- ;
- lda L0570+3
- sta sreg+1
- lda L0570+2
- sta sreg
- lda sreg+1
- bmi L0636
- ;
- ; visible_faces[count].id = i;
- ;
- ldx #$00
- lda L056B
- jsr mulax3
- clc
- adc #<(_visible_faces)
- sta ptr1
- txa
- adc #>(_visible_faces)
- sta ptr1+1
- lda regbank+5
- sta (ptr1)
- ;
- ; visible_faces[count].z_depth = vz[p1] + vz[p2] + vz[p3];
- ;
- ldx #$00
- lda L056B
- jsr mulax3
- clc
- adc #<(_visible_faces)
- tay
- txa
- adc #>(_visible_faces)
- tax
- tya
- jsr pushax
- lda #<(_vz)
- ldx #>(_vz)
- clc
- adc L0568
- bcc L066B
- inx
- L066B: ldy #$00
- jsr ldaidx
- jsr pushax
- lda #<(_vz)
- ldx #>(_vz)
- clc
- adc L0569
- bcc L066D
- inx
- L066D: ldy #$00
- jsr ldaidx
- jsr tosaddax
- jsr pushax
- lda #<(_vz)
- ldx #>(_vz)
- clc
- adc L056A
- bcc L066F
- inx
- L066F: ldy #$00
- jsr ldaidx
- jsr tosaddax
- ldy #$01
- jsr staxspidx
- ;
- ; count++;
- ;
- inc L056B
- ;
- ; for (i = 0; i < 12; ++i) {
- ;
- L0636: inc regbank+5
- jmp L0713
- ;
- ; for (i = 1; i < count; ++i) {
- ;
- L0714: lda #$01
- sta regbank+5
- ldx #$00
- L0715: lda regbank+5
- cmp L056B
- jcs L071A
- ;
- ; temp_face = visible_faces[i];
- ;
- lda #<(L0571)
- ldx #>(L0571)
- jsr pushax
- ldx #$00
- lda regbank+5
- jsr mulax3
- clc
- adc #<(_visible_faces)
- tay
- txa
- adc #>(_visible_faces)
- tax
- tya
- jsr pushax
- ldx #$00
- lda #$03
- jsr _memcpy
- ;
- ; j_sort = i - 1;
- ;
- ldx #$00
- lda regbank+5
- ;
- ; while (j_sort >= 0 && visible_faces[j_sort].z_depth < temp_face.z_depth) {
- ;
- bra L071E
- ;
- ; visible_faces[j_sort + 1] = visible_faces[j_sort];
- ;
- L067F: lda L0572
- ldx L0572+1
- ina
- bne L0688
- inx
- L0688: jsr mulax3
- clc
- adc #<(_visible_faces)
- tay
- txa
- adc #>(_visible_faces)
- tax
- tya
- jsr pushax
- lda L0572
- ldx L0572+1
- jsr mulax3
- clc
- adc #<(_visible_faces)
- tay
- txa
- adc #>(_visible_faces)
- tax
- tya
- jsr pushax
- ldx #$00
- lda #$03
- jsr _memcpy
- ;
- ; j_sort--;
- ;
- lda L0572
- ldx L0572+1
- L071E: sec
- sbc #$01
- bcs L068C
- dex
- L068C: sta L0572
- stx L0572+1
- ;
- ; while (j_sort >= 0 && visible_faces[j_sort].z_depth < temp_face.z_depth) {
- ;
- ldx L0572+1
- bmi L070B
- lda L0572
- ldx L0572+1
- jsr mulax3
- clc
- adc #<(_visible_faces)
- sta ptr1
- txa
- adc #>(_visible_faces)
- sta ptr1+1
- ldy #$02
- lda (ptr1),y
- tax
- dey
- lda (ptr1),y
- cmp L0571+1
- txa
- sbc L0571+1+1
- bvc L070A
- eor #$80
- L070A: bmi L067F
- ;
- ; visible_faces[j_sort + 1] = temp_face;
- ;
- L070B: lda L0572
- ldx L0572+1
- ina
- bne L068F
- inx
- L068F: jsr mulax3
- clc
- adc #<(_visible_faces)
- tay
- txa
- adc #>(_visible_faces)
- tax
- tya
- jsr pushax
- lda #<(L0571)
- ldx #>(L0571)
- jsr pushax
- ldx #$00
- lda #$03
- jsr _memcpy
- ;
- ; for (i = 1; i < count; ++i) {
- ;
- ldx #$00
- inc regbank+5
- jmp L0715
- ;
- ; for (i = 0; i < count; ++i) {
- ;
- L071A: stz regbank+5
- L0718: lda regbank+5
- cmp L056B
- jcs L0692
- ;
- ; f = visible_faces[i].id;
- ;
- jsr mulax3
- sta ptr1
- txa
- clc
- adc #>(_visible_faces)
- sta ptr1+1
- ldy #<(_visible_faces)
- lda (ptr1),y
- sta L0567
- ;
- ; p1 = faces[f][0];
- ;
- ldx #$00
- lda L0567
- jsr mulax3
- sta ptr1
- txa
- clc
- adc #>(_faces)
- sta ptr1+1
- ldy #<(_faces)
- lda (ptr1),y
- sta L0568
- ;
- ; p2 = faces[f][1];
- ;
- ldx #$00
- lda L0567
- jsr mulax3
- clc
- adc #<(_faces)
- sta ptr1
- txa
- adc #>(_faces)
- sta ptr1+1
- ldy #$01
- lda (ptr1),y
- sta L0569
- ;
- ; p3 = faces[f][2];
- ;
- ldx #$00
- lda L0567
- jsr mulax3
- clc
- adc #<(_faces)
- sta ptr1
- txa
- adc #>(_faces)
- sta ptr1+1
- iny
- lda (ptr1),y
- sta L056A
- ;
- ; px[p1], py[p1],
- ;
- jsr decsp7
- lda #<(_px)
- ldx #>(_px)
- clc
- adc L0568
- bcc L06AB
- inx
- L06AB: ldy #$00
- jsr ldaidx
- ldy #$06
- sta (sp),y
- lda #<(_py)
- ldx #>(_py)
- clc
- adc L0568
- bcc L06AE
- inx
- L06AE: ldy #$00
- jsr ldaidx
- ldy #$05
- sta (sp),y
- ;
- ; px[p2], py[p2],
- ;
- lda #<(_px)
- ldx #>(_px)
- clc
- adc L0569
- bcc L06B1
- inx
- L06B1: ldy #$00
- jsr ldaidx
- ldy #$04
- sta (sp),y
- lda #<(_py)
- ldx #>(_py)
- clc
- adc L0569
- bcc L06B4
- inx
- L06B4: ldy #$00
- jsr ldaidx
- ldy #$03
- sta (sp),y
- ;
- ; px[p3], py[p3],
- ;
- lda #<(_px)
- ldx #>(_px)
- clc
- adc L056A
- bcc L06B7
- inx
- L06B7: ldy #$00
- jsr ldaidx
- ldy #$02
- sta (sp),y
- lda #<(_py)
- ldx #>(_py)
- clc
- adc L056A
- bcc L06BA
- inx
- L06BA: ldy #$00
- jsr ldaidx
- iny
- sta (sp),y
- ;
- ; face_colors[f],
- ;
- ldy L0567
- lda _face_colors,y
- sta (sp)
- ;
- ; );
- ;
- lda #$01
- jsr _gpu_draw_tri
- ;
- ; for (i = 0; i < count; ++i) {
- ;
- ldx #$00
- inc regbank+5
- jmp L0718
- ;
- ; via_wait_frame();
- ;
- L0692: jsr _via_wait_frame
- ;
- ; while (1) {
- ;
- jmp L05B7
- .endproc
Advertisement