mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 11:06:06 -04:00
Merge branch 'master' into ModernLighting
This commit is contained in:
commit
64c4582b01
1
.github/workflows/build_3ds.yml
vendored
1
.github/workflows/build_3ds.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (3DS)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_dreamcast.yml
vendored
1
.github/workflows/build_dreamcast.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (Dreamcast)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_freebsd.yml
vendored
1
.github/workflows/build_freebsd.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (FreeBSD)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_haiku.yml
vendored
1
.github/workflows/build_haiku.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (Haiku)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_ios.yml
vendored
1
.github/workflows/build_ios.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (iOS)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_linux.yml
vendored
1
.github/workflows/build_linux.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (Linux)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
- ModernLighting
|
- ModernLighting
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
1
.github/workflows/build_mac64.yml
vendored
1
.github/workflows/build_mac64.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (macOS 64 bit)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_n64.yml
vendored
1
.github/workflows/build_n64.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (N64)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_nds.yml
vendored
1
.github/workflows/build_nds.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (NDS)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
3
.github/workflows/build_netbsd.yml
vendored
3
.github/workflows/build_netbsd.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (NetBSD)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ghcr.io/cross-rs/x86_64-unknown-netbsd
|
image: ghcr.io/cross-rs/x86_64-unknown-netbsd:edge
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Install prerequisites
|
- name: Install prerequisites
|
||||||
|
1
.github/workflows/build_ps2.yml
vendored
1
.github/workflows/build_ps2.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (PS2)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_ps3.yml
vendored
1
.github/workflows/build_ps3.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (PS3)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_psp.yml
vendored
1
.github/workflows/build_psp.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (PSP)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_rpi.yml
vendored
1
.github/workflows/build_rpi.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (RPI)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
3
.github/workflows/build_saturn.yml
vendored
3
.github/workflows/build_saturn.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (Saturn)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
@ -20,6 +21,8 @@ jobs:
|
|||||||
- name: Compile Saturn build
|
- name: Compile Saturn build
|
||||||
id: compile
|
id: compile
|
||||||
run: |
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get -y install curl
|
||||||
make saturn
|
make saturn
|
||||||
|
|
||||||
- uses: ./.github/actions/notify_failure
|
- uses: ./.github/actions/notify_failure
|
||||||
|
1
.github/workflows/build_switch.yml
vendored
1
.github/workflows/build_switch.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (Switch)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_vita.yml
vendored
1
.github/workflows/build_vita.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (Vita)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_webclient.yml
vendored
1
.github/workflows/build_webclient.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (Webclient)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_wiigc.yml
vendored
1
.github/workflows/build_wiigc.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (Wii/GameCube)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_wiiu.yml
vendored
1
.github/workflows/build_wiiu.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (WiiU)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_win-arm.yml
vendored
1
.github/workflows/build_win-arm.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (Windows ARM32/64)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_windows.yml
vendored
1
.github/workflows/build_windows.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (Windows)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
- ModernLighting
|
- ModernLighting
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
1
.github/workflows/build_xbox.yml
vendored
1
.github/workflows/build_xbox.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (Xbox)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
1
.github/workflows/build_xbox360.yml
vendored
1
.github/workflows/build_xbox360.yml
vendored
@ -3,6 +3,7 @@ name: Build latest (Xbox 360)
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -97,6 +97,8 @@ CMakeCache.txt
|
|||||||
|
|
||||||
#GCC object files
|
#GCC object files
|
||||||
*.o
|
*.o
|
||||||
|
# Build dependency files
|
||||||
|
*.d
|
||||||
|
|
||||||
# Roslyn cache directories
|
# Roslyn cache directories
|
||||||
*.ide/
|
*.ide/
|
||||||
|
@ -1,126 +1,93 @@
|
|||||||
!r0 = prefetch address
|
!r0 = clip flags
|
||||||
!r1 = GPU VERT command
|
!r1 = GPU command
|
||||||
!r2 = GPU EOS command
|
!r2 = temp
|
||||||
!r3 = colour
|
!r3 = prefetch address
|
||||||
!r4 = src pointer ARG
|
!r4 = src pointer ARG
|
||||||
!r5 = dst pointer ARG
|
!r5 = dst pointer ARG
|
||||||
!r6 = quads count ARG
|
!r6 = quads count ARG
|
||||||
|
!r7 = ?
|
||||||
|
|
||||||
|
!fr0 = temp
|
||||||
|
!fr1 = u (0.0)
|
||||||
|
!fr2 = v (0.0)
|
||||||
|
!fr3 = c
|
||||||
!fr4 = x
|
!fr4 = x
|
||||||
!fr5 = y
|
!fr5 = y
|
||||||
!fr6 = z
|
!fr6 = z
|
||||||
!fr7 = w
|
!fr7 = w
|
||||||
!fr9 = 0
|
!fr8 = VIEWPORT_HWIDTH
|
||||||
!fr10 = ?
|
!fr9 = VIEWPORT_HHEIGHT
|
||||||
!fr11 = ?
|
!fr10 = VIEWPORT_X_PLUS_HWIDTH
|
||||||
|
!fr11 = VIEWPORT_Y_PLUS_HHEIGHT
|
||||||
|
|
||||||
!fv4 = XYZW
|
!fv4 = XYZW
|
||||||
|
|
||||||
.globl _DrawColouredQuads
|
#include "ViewportTransform.S"
|
||||||
|
.global _DrawColouredQuads
|
||||||
.align 4
|
.align 4
|
||||||
.type _DrawColouredQuads,%function
|
.type _DrawColouredQuads,%function
|
||||||
|
|
||||||
! See https://shared-ptr.com/sh_insns.html
|
|
||||||
! Although there is fmov.s @Rm+,FRn, there isn't fmov.s FRn,@Rm+
|
|
||||||
! So have to use fmov.s FRn,@-Rm instead
|
|
||||||
|
|
||||||
_DrawColouredQuads:
|
_DrawColouredQuads:
|
||||||
! Setup
|
! Setup
|
||||||
mov.l CMD_COL_VERT, r1 ! r1 = GPU VERT command
|
fldi0 fr1 ! U = 0
|
||||||
mov.l CMD_COL_EOS, r2 ! r2 = GPU EOS command
|
fldi0 fr2 ! V = 0
|
||||||
fldi0 fr9 ! fr9 = 0
|
mov r4,r3 ! r3 = src
|
||||||
mov r4,r0 ! r0 = src
|
add #-32, r5 ! r5 -= sizeof(VERTEX)
|
||||||
add #-32, r5 ! r5 -= sizeof(VERTEX)
|
ViewportTransformSetup _VP_COL_HWIDTH
|
||||||
nop ! align loop
|
|
||||||
|
|
||||||
.TRANSFORM_QUAD:
|
.TRANSFORM_QUAD:
|
||||||
! TRANSFORM VERTEX 1
|
mov.l CMD_COL_VERT, r1 ! r1 = GPU VERT command
|
||||||
add #16, r0 ! r0 += VERTEX_STRIDE
|
|
||||||
add #64, r5 ! r5 += 2 * sizeof(VERTEX)
|
|
||||||
pref @r0 ! PREFETCH r0 (next vertex)
|
|
||||||
fmov @r4+, fr4 ! fr4 = src->x
|
|
||||||
fmov @r4+, fr5 ! fr5 = src->y
|
|
||||||
fmov @r4+, fr6 ! fr6 = src->z
|
|
||||||
fldi1 fr7 ! fr7 = 1.0
|
|
||||||
ftrv xmtrx, fv4 ! TRANSFORM(fr4..fr7)
|
|
||||||
|
|
||||||
mov.l @r4+,r3 ! r3 = src->color
|
LoadColouredVertex
|
||||||
fmov.s fr7,@-r5 ! dst->w = fr7
|
ProcessVertex1
|
||||||
mov.l r3,@-r5 ! dst->bgra = r3
|
|
||||||
fmov.s fr9,@-r5 ! dst->v = 0.0
|
|
||||||
fmov.s fr9,@-r5 ! dst->u = 0.0
|
|
||||||
fmov.s fr6,@-r5 ! dst->z = fr6
|
|
||||||
fmov.s fr5,@-r5 ! dst->y = fr5
|
|
||||||
fmov.s fr4,@-r5 ! dst->x = fr4
|
|
||||||
mov.l r1,@-r5 ! dst->flags = CMD_VERT
|
|
||||||
|
|
||||||
! TRANSFORM VERTEX 2
|
LoadColouredVertex
|
||||||
add #16, r0 ! r0 += VERTEX_STRIDE
|
ProcessVertex2
|
||||||
add #64, r5 ! r5 += 2 * sizeof(VERTEX)
|
|
||||||
pref @r0 ! PREFETCH r0 (next vertex)
|
|
||||||
fmov @r4+, fr4 ! fr4 = src->x
|
|
||||||
fmov @r4+, fr5 ! fr5 = src->y
|
|
||||||
fmov @r4+, fr6 ! fr6 = src->z
|
|
||||||
fldi1 fr7 ! fr7 = 1.0
|
|
||||||
ftrv xmtrx, fv4 ! TRANSFORM(fr4..fr7)
|
|
||||||
|
|
||||||
mov.l @r4+,r3 ! r3 = src->color
|
LoadColouredVertex
|
||||||
fmov.s fr7,@-r5 ! dst->w = fr7
|
ProcessVertex3
|
||||||
mov.l r3,@-r5 ! dst->bgra = r3
|
|
||||||
fmov.s fr9,@-r5 ! dst->v = 0.0
|
|
||||||
fmov.s fr9,@-r5 ! dst->u = 0.0
|
|
||||||
fmov.s fr6,@-r5 ! dst->z = fr6
|
|
||||||
fmov.s fr5,@-r5 ! dst->y = fr5
|
|
||||||
fmov.s fr4,@-r5 ! dst->x = fr4
|
|
||||||
mov.l r1,@-r5 ! dst->flags = CMD_VERT
|
|
||||||
|
|
||||||
! TRANSFORM VERTEX 3
|
LoadColouredVertex
|
||||||
add #16, r0 ! r0 += VERTEX_STRIDE
|
ProcessVertex4 CMD_COL_EOS
|
||||||
add #64, r5 ! r5 += 2 * sizeof(VERTEX)
|
|
||||||
pref @r0 ! PREFETCH r0 (next vertex)
|
|
||||||
fmov @r4+, fr4 ! fr4 = src->x
|
|
||||||
fmov @r4+, fr5 ! fr5 = src->y
|
|
||||||
fmov @r4+, fr6 ! fr6 = src->z
|
|
||||||
fldi1 fr7 ! fr7 = 1.0
|
|
||||||
ftrv xmtrx, fv4 ! TRANSFORM(fr4..fr7)
|
|
||||||
|
|
||||||
mov.l @r4+,r3 ! r3 = src->color
|
! CLIPFLAGS TESTING
|
||||||
fmov.s fr7,@-r5 ! dst->w = fr7
|
cmp/eq #0,r0 ! T = r0 == 0 (all points invisible)
|
||||||
mov.l r3,@-r5 ! dst->bgra = r3
|
bt/s .NO_POINTS_VISIBLE ! if T goto NO_POINTS_VISIBLE
|
||||||
fmov.s fr9,@-r5 ! dst->v = 0.0
|
nop
|
||||||
fmov.s fr9,@-r5 ! dst->u = 0.0
|
bra .SOME_POINTS_VISIBLE
|
||||||
fmov.s fr6,@-r5 ! dst->z = fr6
|
nop
|
||||||
fmov.s fr5,@-r5 ! dst->y = fr5
|
|
||||||
fmov.s fr4,@-r5 ! dst->x = fr4
|
|
||||||
mov.l r1,@-r5 ! dst->flags = CMD_VERT
|
|
||||||
|
|
||||||
! TRANSFORM VERTEX 4
|
.NO_POINTS_VISIBLE:
|
||||||
add #16, r0 ! r0 += VERTEX_STRIDE
|
bra .LOOP_END ! jump to loop end after executing instruction in delay slot
|
||||||
add #64, r5 ! r5 += 2 * sizeof(VERTEX)
|
add #-128, r5 ! r5 -= 4 * sizeof(VERTEX), move back to 1 vertex before start of quad
|
||||||
pref @r0 ! PREFETCH r0 (next vertex)
|
|
||||||
fmov @r4+, fr4 ! fr4 = src->x
|
|
||||||
fmov @r4+, fr5 ! fr5 = src->y
|
|
||||||
fmov @r4+, fr6 ! fr6 = src->z
|
|
||||||
fldi1 fr7 ! fr7 = 1.0
|
|
||||||
ftrv xmtrx, fv4 ! TRANSFORM(fr4..fr7)
|
|
||||||
|
|
||||||
mov.l @r4+,r3 ! r3 = src->color
|
.SOME_POINTS_VISIBLE:
|
||||||
fmov.s fr7,@-r5 ! dst->w = fr7
|
|
||||||
mov.l r3,@-r5 ! dst->bgra = r3
|
|
||||||
fmov.s fr9,@-r5 ! dst->v = 0.0
|
|
||||||
fmov.s fr9,@-r5 ! dst->u = 0.0
|
|
||||||
fmov.s fr6,@-r5 ! dst->z = fr6
|
|
||||||
fmov.s fr5,@-r5 ! dst->y = fr5
|
|
||||||
fmov.s fr4,@-r5 ! dst->x = fr4
|
|
||||||
mov.l r2,@-r5 ! dst->flags = CMD_EOS
|
|
||||||
|
|
||||||
dt r6 ! r6--; T = 1 if r6 == 0, else 0
|
.LOOP_END:
|
||||||
bf .TRANSFORM_QUAD ! if T == 0 then goto TRANSFORM_QUAD
|
dt r6 ! r6--; T = r6 == 0
|
||||||
|
bf .TRANSFORM_QUAD ! if !T then goto TRANSFORM_QUAD
|
||||||
nop
|
nop
|
||||||
|
|
||||||
rts ! return
|
add #32, r5 ! r5 += sizeof(VERTEX)
|
||||||
nop
|
rts ! return after executing instruction in delay slot
|
||||||
|
mov r5,r0 ! r0 = r5
|
||||||
|
|
||||||
.align 2
|
.align 2
|
||||||
CMD_COL_VERT: .long 0xe0000000
|
CMD_COL_VERT: .long 0xe0000000
|
||||||
CMD_COL_EOS: .long 0xf0000000
|
CMD_COL_EOS: .long 0xf0000000
|
||||||
|
|
||||||
|
.global _VP_COL_HWIDTH
|
||||||
|
.type _VP_COL_HWIDTH,%object
|
||||||
|
_VP_COL_HWIDTH: .long 0
|
||||||
|
|
||||||
|
.global _VP_COL_HHEIGHT
|
||||||
|
.type _VP_COL_HHEIGHT,%object
|
||||||
|
_VP_COL_HHEIGHT: .long 0
|
||||||
|
|
||||||
|
.global _VP_COL_X_PLUS_HWIDTH
|
||||||
|
.type _VP_COL_X_PLUS_HWIDTH,%object
|
||||||
|
_VP_COL_X_PLUS_HWIDTH: .long 0
|
||||||
|
|
||||||
|
.global _VP_COL_Y_PLUS_HHEIGHT
|
||||||
|
.type _VP_COL_Y_PLUS_HHEIGHT,%object
|
||||||
|
_VP_COL_Y_PLUS_HHEIGHT: .long 0
|
@ -1,128 +1,91 @@
|
|||||||
!r0 = prefetch address
|
!r0 = clip flags
|
||||||
!r1 = GPU VERT command
|
!r1 = GPU command
|
||||||
!r2 = GPU EOS command
|
!r2 = temp
|
||||||
!r3 = colour
|
!r3 = prefetch address
|
||||||
!r4 = src pointer ARG
|
!r4 = src pointer ARG
|
||||||
!r5 = dst pointer ARG
|
!r5 = dst pointer ARG
|
||||||
!r6 = quads count ARG
|
!r6 = quads count ARG
|
||||||
|
!r7 = ?
|
||||||
|
|
||||||
|
!fr0 = temp
|
||||||
|
!fr1 = u
|
||||||
|
!fr2 = v
|
||||||
|
!fr3 = c
|
||||||
!fr4 = x
|
!fr4 = x
|
||||||
!fr5 = y
|
!fr5 = y
|
||||||
!fr6 = z
|
!fr6 = z
|
||||||
!fr7 = w
|
!fr7 = w
|
||||||
!fr9 = ?
|
!fr8 = VIEWPORT_HWIDTH
|
||||||
!fr10 = u
|
!fr9 = VIEWPORT_HHEIGHT
|
||||||
!fr11 = v
|
!fr10 = VIEWPORT_X_PLUS_HWIDTH
|
||||||
|
!fr11 = VIEWPORT_Y_PLUS_HHEIGHT
|
||||||
|
|
||||||
!fv4 = XYZW
|
!fv4 = XYZW
|
||||||
|
|
||||||
.globl _DrawTexturedQuads
|
#include "ViewportTransform.S"
|
||||||
|
.global _DrawTexturedQuads
|
||||||
.align 4
|
.align 4
|
||||||
.type _DrawTexturedQuads,%function
|
.type _DrawTexturedQuads,%function
|
||||||
|
|
||||||
_DrawTexturedQuads:
|
_DrawTexturedQuads:
|
||||||
! Setup
|
! Setup
|
||||||
mov.l CMD_TEX_VERT, r1 ! r1 = GPU VERT command
|
mov r4,r3 ! r3 = src
|
||||||
mov.l CMD_TEX_EOS, r2 ! r2 = GPU EOS command
|
add #-32, r5 ! r5 -= sizeof(VERTEX)
|
||||||
mov r4,r0 ! r0 = src
|
ViewportTransformSetup _VP_TEX_HWIDTH
|
||||||
add #-32, r5 ! r5 -= sizeof(VERTEX)
|
|
||||||
|
|
||||||
.TRANSFORM_QUAD:
|
.TRANSFORM_QUAD:
|
||||||
! TRANSFORM VERTEX 1
|
mov.l CMD_TEX_VERT, r1 ! r1 = GPU VERT command
|
||||||
add #24, r0 ! r0 += VERTEX_STRIDE
|
|
||||||
add #64, r5 ! r5 += 2 * sizeof(VERTEX)
|
|
||||||
pref @r0 ! PREFETCH r0 (next vertex)
|
|
||||||
fmov @r4+, fr4 ! fr4 = src->x
|
|
||||||
fmov @r4+, fr5 ! fr5 = src->y
|
|
||||||
fmov @r4+, fr6 ! fr6 = src->z
|
|
||||||
fldi1 fr7 ! fr7 = 1.0
|
|
||||||
ftrv xmtrx, fv4 ! TRANSFORM(fr4..fr7)
|
|
||||||
|
|
||||||
mov.l @r4+,r3 ! r3 = src->color
|
LoadTexturedVertex
|
||||||
fmov @r4+,fr10! fr10 = src->u
|
ProcessVertex1
|
||||||
fmov @r4+,fr11! fr11 = src->v
|
|
||||||
fmov.s fr7,@-r5 ! dst->w = fr7
|
|
||||||
mov.l r3,@-r5 ! dst->bgra = r3
|
|
||||||
fmov.s fr11,@-r5 ! dst->v = fr11
|
|
||||||
fmov.s fr10,@-r5 ! dst->u = fr10
|
|
||||||
fmov.s fr6,@-r5 ! dst->z = fr6
|
|
||||||
fmov.s fr5,@-r5 ! dst->y = fr5
|
|
||||||
fmov.s fr4,@-r5 ! dst->x = fr4
|
|
||||||
mov.l r1,@-r5 ! dst->flags = CMD_VERT
|
|
||||||
|
|
||||||
! TRANSFORM VERTEX 2
|
LoadTexturedVertex
|
||||||
add #24, r0 ! r0 += VERTEX_STRIDE
|
ProcessVertex2
|
||||||
add #64, r5 ! r5 += 2 * sizeof(VERTEX)
|
|
||||||
pref @r0 ! PREFETCH r0 (next vertex)
|
|
||||||
fmov @r4+, fr4 ! fr4 = src->x
|
|
||||||
fmov @r4+, fr5 ! fr5 = src->y
|
|
||||||
fmov @r4+, fr6 ! fr6 = src->z
|
|
||||||
fldi1 fr7 ! fr7 = 1.0
|
|
||||||
ftrv xmtrx, fv4 ! TRANSFORM(fr4..fr7)
|
|
||||||
|
|
||||||
mov.l @r4+,r3 ! r3 = src->color
|
LoadTexturedVertex
|
||||||
fmov @r4+,fr10! fr10 = src->u
|
ProcessVertex3
|
||||||
fmov @r4+,fr11! fr11 = src->v
|
|
||||||
fmov.s fr7,@-r5 ! dst->w = fr7
|
|
||||||
mov.l r3,@-r5 ! dst->bgra = r3
|
|
||||||
fmov.s fr11,@-r5 ! dst->v = fr11
|
|
||||||
fmov.s fr10,@-r5 ! dst->u = fr10
|
|
||||||
fmov.s fr6,@-r5 ! dst->z = fr6
|
|
||||||
fmov.s fr5,@-r5 ! dst->y = fr5
|
|
||||||
fmov.s fr4,@-r5 ! dst->x = fr4
|
|
||||||
mov.l r1,@-r5 ! dst->flags = CMD_VERT
|
|
||||||
|
|
||||||
! TRANSFORM VERTEX 3
|
LoadTexturedVertex
|
||||||
add #24, r0 ! r0 += VERTEX_STRIDE
|
ProcessVertex4 CMD_TEX_EOS
|
||||||
add #64, r5 ! r5 += 2 * sizeof(VERTEX)
|
|
||||||
pref @r0 ! PREFETCH r0 (next vertex)
|
|
||||||
fmov @r4+, fr4 ! fr4 = src->x
|
|
||||||
fmov @r4+, fr5 ! fr5 = src->y
|
|
||||||
fmov @r4+, fr6 ! fr6 = src->z
|
|
||||||
fldi1 fr7 ! fr7 = 1.0
|
|
||||||
ftrv xmtrx, fv4 ! TRANSFORM(fr4..fr7)
|
|
||||||
|
|
||||||
mov.l @r4+,r3 ! r3 = src->color
|
! CLIPFLAGS TESTING
|
||||||
fmov @r4+,fr10! fr10 = src->u
|
cmp/eq #0,r0 ! T = r0 == 0 (all points invisible)
|
||||||
fmov @r4+,fr11! fr11 = src->v
|
bt/s .NO_POINTS_VISIBLE ! if T goto NO_POINTS_VISIBLE
|
||||||
fmov.s fr7,@-r5 ! dst->w = fr7
|
nop
|
||||||
mov.l r3,@-r5 ! dst->bgra = r3
|
bra .SOME_POINTS_VISIBLE
|
||||||
fmov.s fr11,@-r5 ! dst->v = fr11
|
nop
|
||||||
fmov.s fr10,@-r5 ! dst->u = fr10
|
|
||||||
fmov.s fr6,@-r5 ! dst->z = fr6
|
|
||||||
fmov.s fr5,@-r5 ! dst->y = fr5
|
|
||||||
fmov.s fr4,@-r5 ! dst->x = fr4
|
|
||||||
mov.l r1,@-r5 ! dst->flags = CMD_VERT
|
|
||||||
|
|
||||||
! TRANSFORM VERTEX 4
|
.NO_POINTS_VISIBLE:
|
||||||
add #24, r0 ! r0 += VERTEX_STRIDE
|
bra .LOOP_END ! jump to loop end after executing instruction in delay slot
|
||||||
add #64, r5 ! r5 += 2 * sizeof(VERTEX)
|
add #-128, r5 ! r5 -= 4 * sizeof(VERTEX), move back to prior quad, so that this invisible quad gets overwritten in next iteration
|
||||||
pref @r0 ! PREFETCH r0 (next vertex)
|
|
||||||
fmov @r4+, fr4 ! fr4 = src->x
|
|
||||||
fmov @r4+, fr5 ! fr5 = src->y
|
|
||||||
fmov @r4+, fr6 ! fr6 = src->z
|
|
||||||
fldi1 fr7 ! fr7 = 1.0
|
|
||||||
ftrv xmtrx, fv4 ! TRANSFORM(fr4..fr7)
|
|
||||||
|
|
||||||
mov.l @r4+,r3 ! r3 = src->color
|
.SOME_POINTS_VISIBLE:
|
||||||
fmov @r4+,fr10! fr10 = src->u
|
|
||||||
fmov @r4+,fr11! fr11 = src->v
|
|
||||||
fmov.s fr7,@-r5 ! dst->w = fr7
|
|
||||||
mov.l r3,@-r5 ! dst->bgra = r3
|
|
||||||
fmov.s fr11,@-r5 ! dst->v = fr11
|
|
||||||
fmov.s fr10,@-r5 ! dst->u = fr10
|
|
||||||
fmov.s fr6,@-r5 ! dst->z = fr6
|
|
||||||
fmov.s fr5,@-r5 ! dst->y = fr5
|
|
||||||
fmov.s fr4,@-r5 ! dst->x = fr4
|
|
||||||
mov.l r2,@-r5 ! dst->flags = CMD_EOS
|
|
||||||
|
|
||||||
dt r6 ! r6--; T = 1 if r6 == 0, else 0
|
.LOOP_END:
|
||||||
bf .TRANSFORM_QUAD ! if T == 0 then goto TRANSFORM_QUAD
|
dt r6 ! r6--; T = r6 == 0
|
||||||
|
bf .TRANSFORM_QUAD ! if !T then goto TRANSFORM_QUAD
|
||||||
nop
|
nop
|
||||||
|
|
||||||
rts ! return
|
add #32, r5 ! r5 += sizeof(VERTEX)
|
||||||
nop
|
rts ! return after executing instruction in delay slot
|
||||||
|
mov r5,r0 ! r0 = r5
|
||||||
|
|
||||||
.align 2
|
.align 2
|
||||||
CMD_TEX_VERT: .long 0xe0000000
|
CMD_TEX_VERT: .long 0xe0000000
|
||||||
CMD_TEX_EOS: .long 0xf0000000
|
CMD_TEX_EOS: .long 0xf0000000
|
||||||
|
|
||||||
|
.global _VP_TEX_HWIDTH
|
||||||
|
.type _VP_TEX_HWIDTH,%object
|
||||||
|
_VP_TEX_HWIDTH: .long 0
|
||||||
|
|
||||||
|
.global _VP_TEX_HHEIGHT
|
||||||
|
.type _VP_TEX_HHEIGHT,%object
|
||||||
|
_VP_TEX_HHEIGHT: .long 0
|
||||||
|
|
||||||
|
.global _VP_TEX_X_PLUS_HWIDTH
|
||||||
|
.type _VP_TEX_X_PLUS_HWIDTH,%object
|
||||||
|
_VP_TEX_X_PLUS_HWIDTH: .long 0
|
||||||
|
|
||||||
|
.global _VP_TEX_Y_PLUS_HHEIGHT
|
||||||
|
.type _VP_TEX_Y_PLUS_HHEIGHT,%object
|
||||||
|
_VP_TEX_Y_PLUS_HHEIGHT: .long 0
|
@ -11,7 +11,7 @@ LDFLAGS=-g
|
|||||||
LIBS=-lm $(GLDC_LIB) -lppp -lkosfat
|
LIBS=-lm $(GLDC_LIB) -lppp -lkosfat
|
||||||
|
|
||||||
TARGET := ClassiCube-dc
|
TARGET := ClassiCube-dc
|
||||||
CC_TEXTURES = classicube.zip
|
CC_TEXTURES = misc/dreamcast/classicube.zip
|
||||||
|
|
||||||
ifeq ($(strip $(KOS_BASE)),)
|
ifeq ($(strip $(KOS_BASE)),)
|
||||||
$(error "Please set KOS variables in your environment.")
|
$(error "Please set KOS variables in your environment.")
|
||||||
|
@ -1,49 +1,161 @@
|
|||||||
|
! =========================================================
|
||||||
|
! ========================= VERTEX LOADING ================
|
||||||
|
! =========================================================
|
||||||
|
.macro LoadColouredVertex
|
||||||
|
! PREPARE NEXT VERTEX
|
||||||
|
add #16, r3 ! r3 += VERTEX_STRIDE
|
||||||
|
pref @r3 ! PREFETCH r3 (next vertex)
|
||||||
|
add #64, r5 ! r5 += 2 * sizeof(VERTEX)
|
||||||
|
! LOAD XYZ
|
||||||
|
fmov @r4+, fr4 ! X = src->x
|
||||||
|
fmov @r4+, fr5 ! Y = src->y
|
||||||
|
fmov @r4+, fr6 ! Z = src->z
|
||||||
|
fldi1 fr7 ! W = 1.0
|
||||||
|
! TRANSFORM VERTEX
|
||||||
|
ftrv xmtrx, fv4 ! TRANSFORM(XYZW)
|
||||||
|
! LOAD ATTRIBUTES
|
||||||
|
fmov @r4+,fr3 ! C = src->color
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.macro LoadTexturedVertex
|
||||||
|
! PREPARE NEXT VERTEX
|
||||||
|
add #24, r3 ! r3 += VERTEX_STRIDE
|
||||||
|
pref @r3 ! PREFETCH r3 (next vertex)
|
||||||
|
add #64, r5 ! r5 += 2 * sizeof(VERTEX)
|
||||||
|
! LOAD XYZ
|
||||||
|
fmov @r4+, fr4 ! X = src->x
|
||||||
|
fmov @r4+, fr5 ! Y = src->y
|
||||||
|
fmov @r4+, fr6 ! Z = src->z
|
||||||
|
fldi1 fr7 ! W = 1.0
|
||||||
|
! TRANSFORM VERTEX
|
||||||
|
ftrv xmtrx, fv4 ! TRANSFORM(XYZW)
|
||||||
|
! LOAD ATTRIBUTES
|
||||||
|
fmov @r4+,fr3 ! C = src->color
|
||||||
|
fmov @r4+,fr1 ! U = src->u
|
||||||
|
fmov @r4+,fr2 ! V = src->v
|
||||||
|
.endm
|
||||||
|
|
||||||
|
! =========================================================
|
||||||
|
! ========================= VERTEX OUTPUT =================
|
||||||
|
! =========================================================
|
||||||
|
! To take advantage of SH4 dual instruction processing, interleave
|
||||||
|
! the clipflag calculation and vertex output instructions
|
||||||
|
.macro ProcessVertex1
|
||||||
|
fmov.s fr7,@-r5 ! dst->w = W
|
||||||
|
fmov.s fr3,@-r5 ! dst->c = C
|
||||||
|
fneg fr7 ! W = -W
|
||||||
|
fmov.s fr2,@-r5 ! dst->v = V
|
||||||
|
fcmp/gt fr7,fr6 ! T = Z > W (i.e. Z > -W)
|
||||||
|
fmov.s fr1,@-r5 ! dst->u = U
|
||||||
|
movt r0 ! CLIPFLAGS = T
|
||||||
|
fmov.s fr6,@-r5 ! dst->z = Z
|
||||||
|
fmov.s fr5,@-r5 ! dst->y = Y
|
||||||
|
fmov.s fr4,@-r5 ! dst->x = X
|
||||||
|
mov.l r1,@-r5 ! dst->flags = CMD_VERT
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.macro ProcessVertex2
|
||||||
|
fmov.s fr7,@-r5 ! dst->w = W
|
||||||
|
fmov.s fr3,@-r5 ! dst->c = C
|
||||||
|
fneg fr7 ! W = -W
|
||||||
|
fmov.s fr2,@-r5 ! dst->v = V
|
||||||
|
fcmp/gt fr7,fr6 ! T = Z > W (i.e. Z > -W)
|
||||||
|
fmov.s fr1,@-r5 ! dst->u = U
|
||||||
|
movt r2 ! tmp = T
|
||||||
|
fmov.s fr6,@-r5 ! dst->z = Z
|
||||||
|
add r2,r2 ! tmp = tmp + tmp
|
||||||
|
fmov.s fr5,@-r5 ! dst->y = Y
|
||||||
|
or r2,r0 ! CLIPFLAGS |= tmp (T << 1)
|
||||||
|
fmov.s fr4,@-r5 ! dst->x = X
|
||||||
|
mov.l r1,@-r5 ! dst->flags = CMD_VERT
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.macro ProcessVertex3
|
||||||
|
fmov.s fr7,@-r5 ! dst->w = W
|
||||||
|
fmov.s fr3,@-r5 ! dst->c = C
|
||||||
|
fneg fr7 ! W = -W
|
||||||
|
fmov.s fr2,@-r5 ! dst->v = V
|
||||||
|
fcmp/gt fr7,fr6 ! T = Z > W (i.e. Z > -W)
|
||||||
|
fmov.s fr1,@-r5 ! dst->u = U
|
||||||
|
movt r2 ! tmp = T
|
||||||
|
fmov.s fr6,@-r5 ! dst->z = Z
|
||||||
|
fmov.s fr5,@-r5 ! dst->y = Y
|
||||||
|
shll2 r2 ! tmp = tmp << 2
|
||||||
|
fmov.s fr4,@-r5 ! dst->x = X
|
||||||
|
or r2,r0 ! CLIPFLAGS |= tmp (T << 2)
|
||||||
|
mov.l r1,@-r5 ! dst->flags = CMD_VERT
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.macro ProcessVertex4 eos_addr
|
||||||
|
fmov.s fr7,@-r5 ! dst->w = W
|
||||||
|
fmov.s fr3,@-r5 ! dst->c = C
|
||||||
|
fneg fr7 ! W = -W
|
||||||
|
fmov.s fr2,@-r5 ! dst->v = V
|
||||||
|
fcmp/gt fr7,fr6 ! T = Z > W (i.e. Z > -W)
|
||||||
|
fmov.s fr1,@-r5 ! dst->u = U
|
||||||
|
movt r2 ! tmp = T
|
||||||
|
fmov.s fr6,@-r5 ! dst->z = Z
|
||||||
|
shll2 r2 ! tmp = tmp << 2
|
||||||
|
fmov.s fr5,@-r5 ! dst->y = Y
|
||||||
|
add r2,r2 ! tmp = (tmp << 2) + (tmp << 2)
|
||||||
|
fmov.s fr4,@-r5 ! dst->x = X
|
||||||
|
mov.l \eos_addr, r1 ! r1 = GPU EOS command
|
||||||
|
or r2,r0 ! CLIPFLAGS |= tmp (T << 3)
|
||||||
|
or r0,r1 ! r1 |= CLIPFLAGS
|
||||||
|
mov.l r1,@-r5 ! dst->flags = GPU EOS | CLIPFLAGS
|
||||||
|
.endm
|
||||||
|
|
||||||
|
|
||||||
|
! =========================================================
|
||||||
|
! ====================== VIEWPORT TRANSFORM ===============
|
||||||
|
! =========================================================
|
||||||
!r2 = return addr
|
!r2 = return addr
|
||||||
!r0 = temp
|
!r0 = temp
|
||||||
!r5 = dst pointer
|
!r5 = dst pointer
|
||||||
|
|
||||||
!fr4 = VIEWPORT_HWIDTH
|
!fr0 = temp
|
||||||
!fr5 = VIEWPORT_HHEIGHT
|
!fr4 = temp
|
||||||
!fr6 = VIEWPORT_X_PLUS_HWIDTH
|
!fr5 = temp
|
||||||
!fr7 = VIEWPORT_Y_PLUS_HHEIGHT
|
!fr5 = temp
|
||||||
!fr8 = ???
|
!fr8 = VIEWPORT_HWIDTH
|
||||||
!fr9 = temp
|
!fr9 = VIEWPORT_HHEIGHT
|
||||||
!fr10 = temp
|
!fr10 = VIEWPORT_X_PLUS_HWIDTH
|
||||||
!fr11 = saved fr0
|
!fr11 = VIEWPORT_Y_PLUS_HHEIGHT
|
||||||
|
|
||||||
.macro ViewportTransformSetup viewport_addr
|
.macro ViewportTransformSetup viewport_addr
|
||||||
mova \viewport_addr, r0
|
mova \viewport_addr, r0
|
||||||
fmov.s @r0+,fr4 ! fr4 = VIEWPORT_HWIDTH
|
fmov.s @r0+,fr8 ! fr8 = VIEWPORT_HWIDTH
|
||||||
fmov.s @r0+,fr5 ! fr5 = VIEWPORT_HHEIGHT
|
fmov.s @r0+,fr9 ! fr9 = VIEWPORT_HHEIGHT
|
||||||
fmov.s @r0+,fr6 ! fr6 = VIEWPORT_X_PLUS_HWIDTH
|
fmov.s @r0+,fr10 ! fr10 = VIEWPORT_X_PLUS_HWIDTH
|
||||||
fmov.s @r0+,fr7 ! fr7 = VIEWPORT_Y_PLUS_HHEIGHT
|
fmov.s @r0+,fr11 ! fr11 = VIEWPORT_Y_PLUS_HHEIGHT
|
||||||
|
nop ! align to even instructions
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro ViewportTransformVertex
|
.macro ViewportTransformVertex
|
||||||
! INVERSE W CALCULATION
|
! INVERSE W CALCULATION
|
||||||
add #28, r5 ! r5 = &vertex[0].w
|
add #28, r5 ! r5 = &vertex->w
|
||||||
fmov.s @r5+,fr0 ! fr0 = vertex->w
|
fmov.s @r5,fr0 ! fr0 = vertex->w
|
||||||
fmul fr0,fr0 ! fr0 = fr0 * fr0
|
fmul fr0,fr0 ! fr0 = fr0 * fr0
|
||||||
add #-32, r5 ! r5 -= sizeof(VERTEX)
|
add #-24, r5 ! r5 = &vertex->x
|
||||||
fsrra fr0 ! fr0 = 1 / sqrt(fr0) -> 1 / vertex->w
|
fsrra fr0 ! fr0 = 1 / sqrt(fr0) -> 1 / vertex->w
|
||||||
|
|
||||||
! TRANSFORM X
|
! TRANSFORM X
|
||||||
fmov.s @r5,fr10 ! fr10 = vertex->x
|
fmov.s @r5,fr4 ! fr4 = vertex->x
|
||||||
fmov fr6,fr9 ! fr9 = VIEWPORT_X_PLUS_HWIDTH
|
fmov fr10,fr5 ! fr5 = VIEWPORT_X_PLUS_HWIDTH
|
||||||
fmul fr4,fr10 ! fr10 = VIEWPORT_HWIDTH * vertex->x
|
fmul fr8,fr4 ! fr4 = VIEWPORT_HWIDTH * vertex->x
|
||||||
fmac fr0,fr10,fr9 ! fr9 = fr0 * fr10 + fr9 -- (X * F * hwidth) + x_plus_hwidth
|
fmac fr0,fr4,fr5 ! fr5 = fr0 * fr4 + fr5 -- (X * F * hwidth) + x_plus_hwidth
|
||||||
fmov.s fr9,@r5 ! vertex->x = fr9
|
fmov.s fr5,@r5 ! vertex->x = fr5
|
||||||
add #4, r5 ! r5 += 4 (points to vertex->y)
|
add #4, r5 ! r5 = &vertex->y
|
||||||
|
|
||||||
! TRANSFORM Y
|
! TRANSFORM Y
|
||||||
fmov.s @r5,fr10 ! fr10 = vertex->y
|
fmov.s @r5,fr4 ! fr4 = vertex->y
|
||||||
fmov fr7,fr9 ! fr9 = VIEWPORT_Y_PLUS_HHEIGHT
|
fmov fr11,fr5 ! fr5 = VIEWPORT_Y_PLUS_HHEIGHT
|
||||||
fmul fr5,fr10 ! fr10 = VIEWPORT_HHEIGHT * vertex->y
|
fmul fr9,fr4 ! fr4 = VIEWPORT_HHEIGHT * vertex->y
|
||||||
fmac fr0,fr10,fr9 ! fr9 = fr0 * fr10 + fr9 -- (Y * F * hheight) + y_plus_hheight
|
fmac fr0,fr4,fr5 ! fr5 = fr0 * fr4 + fr5 -- (Y * F * hheight) + y_plus_hheight
|
||||||
fmov.s fr9,@r5 ! vertex->y = fr9
|
fmov.s fr5,@r5 ! vertex->y = fr5
|
||||||
add #4, r5 ! r5 += 4 (points to vertex->z)
|
add #4, r5 ! r5 = &vertex->z
|
||||||
|
|
||||||
! ASSIGN Z
|
! ASSIGN Z
|
||||||
fmov.s @r5,fr0 ! vertex->z = fr0
|
fmov.s fr0,@r5 ! vertex->z = fr0
|
||||||
add #24, r5 ! r5 += 24 (points to next vertex)
|
add #20, r5 ! r5 += 20 (points to start of next vertex)
|
||||||
.endm
|
.endm
|
@ -31,6 +31,7 @@ static void InitGLState(void) {
|
|||||||
|
|
||||||
void Gfx_Create(void) {
|
void Gfx_Create(void) {
|
||||||
if (!Gfx.Created) glKosInit();
|
if (!Gfx.Created) glKosInit();
|
||||||
|
|
||||||
Gfx_SetViewport(0, 0, Game.Width, Game.Height);
|
Gfx_SetViewport(0, 0, Game.Width, Game.Height);
|
||||||
InitGLState();
|
InitGLState();
|
||||||
|
|
||||||
@ -467,19 +468,34 @@ cc_bool Gfx_WarnIfNecessary(void) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
#define VB_PTR gfx_vertices
|
#define VB_PTR gfx_vertices
|
||||||
static const void* VERTEX_PTR;
|
static const void* VERTEX_PTR;
|
||||||
|
extern void apply_poly_header(PolyHeader* header, PolyList* activePolyList);
|
||||||
|
|
||||||
extern void DrawColouredQuads(const void* src, Vertex* dst, int numQuads);
|
extern Vertex* DrawColouredQuads(const void* src, Vertex* dst, int numQuads);
|
||||||
extern void DrawTexturedQuads(const void* src, Vertex* dst, int numQuads);
|
extern Vertex* DrawTexturedQuads(const void* src, Vertex* dst, int numQuads);
|
||||||
|
|
||||||
void DrawQuads(int count) {
|
void DrawQuads(int count) {
|
||||||
if (!count) return;
|
if (!count) return;
|
||||||
Vertex* start = submitVertices(count);
|
PolyList* output = _glActivePolyList();
|
||||||
|
AlignedVectorHeader* hdr = &output->vector.hdr;
|
||||||
|
|
||||||
|
uint32_t header_required = (hdr->size == 0) || STATE_DIRTY;
|
||||||
|
// Reserve room for the vertices and header
|
||||||
|
Vertex* beg = aligned_vector_reserve(&output->vector, hdr->size + (header_required) + count);
|
||||||
|
|
||||||
|
if (header_required) {
|
||||||
|
apply_poly_header((PolyHeader*)beg, output);
|
||||||
|
STATE_DIRTY = GL_FALSE;
|
||||||
|
beg++;
|
||||||
|
hdr->size += 1;
|
||||||
|
}
|
||||||
|
Vertex* end;
|
||||||
|
|
||||||
if (TEXTURES_ENABLED) {
|
if (TEXTURES_ENABLED) {
|
||||||
DrawTexturedQuads(VERTEX_PTR, start, count >> 2);
|
end = DrawTexturedQuads(VERTEX_PTR, beg, count >> 2);
|
||||||
} else {
|
} else {
|
||||||
DrawColouredQuads(VERTEX_PTR, start, count >> 2);
|
end = DrawColouredQuads(VERTEX_PTR, beg, count >> 2);
|
||||||
}
|
}
|
||||||
|
hdr->size += (end - beg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_SetVertexFormat(VertexFormat fmt) {
|
void Gfx_SetVertexFormat(VertexFormat fmt) {
|
||||||
@ -569,6 +585,11 @@ void Gfx_OnWindowResize(void) {
|
|||||||
Gfx_SetViewport(0, 0, Game.Width, Game.Height);
|
Gfx_SetViewport(0, 0, Game.Width, Game.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern float VP_COL_HWIDTH, VP_TEX_HWIDTH;
|
||||||
|
extern float VP_COL_HHEIGHT, VP_TEX_HHEIGHT;
|
||||||
|
extern float VP_COL_X_PLUS_HWIDTH, VP_TEX_X_PLUS_HWIDTH;
|
||||||
|
extern float VP_COL_Y_PLUS_HHEIGHT, VP_TEX_Y_PLUS_HHEIGHT;
|
||||||
|
|
||||||
void Gfx_SetViewport(int x, int y, int w, int h) {
|
void Gfx_SetViewport(int x, int y, int w, int h) {
|
||||||
if (x == 0 && y == 0 && w == Game.Width && h == Game.Height) {
|
if (x == 0 && y == 0 && w == Game.Width && h == Game.Height) {
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
@ -578,5 +599,11 @@ void Gfx_SetViewport(int x, int y, int w, int h) {
|
|||||||
|
|
||||||
glViewport(x, y, w, h);
|
glViewport(x, y, w, h);
|
||||||
glScissor (x, y, w, h);
|
glScissor (x, y, w, h);
|
||||||
|
|
||||||
|
VP_COL_HWIDTH = VP_TEX_HWIDTH = w * 0.5f;
|
||||||
|
VP_COL_HHEIGHT = VP_TEX_HHEIGHT = h * -0.5f;
|
||||||
|
|
||||||
|
VP_COL_X_PLUS_HWIDTH = VP_TEX_X_PLUS_HWIDTH = x + w * 0.5f;
|
||||||
|
VP_COL_Y_PLUS_HHEIGHT = VP_TEX_Y_PLUS_HHEIGHT = y + h * 0.5f;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,7 +36,6 @@ static RenderBuffer buffers[2];
|
|||||||
static cc_uint8* next_packet;
|
static cc_uint8* next_packet;
|
||||||
static int active_buffer;
|
static int active_buffer;
|
||||||
static RenderBuffer* buffer;
|
static RenderBuffer* buffer;
|
||||||
static cc_bool rendering2D;
|
|
||||||
static void* lastPoly;
|
static void* lastPoly;
|
||||||
static cc_bool cullingEnabled;
|
static cc_bool cullingEnabled;
|
||||||
|
|
||||||
@ -672,7 +671,6 @@ static void DrawColouredQuads3D(int verticesCount, int startVertex) {
|
|||||||
poly->b0 = PackedCol_B(v->Col);
|
poly->b0 = PackedCol_B(v->Col);
|
||||||
//if (VERTEX_LOGGING) Platform_Log4("OUT: %i, %i, %i (%i)", &X, &Y, &Z, &p);
|
//if (VERTEX_LOGGING) Platform_Log4("OUT: %i, %i, %i (%i)", &X, &Y, &Z, &p);
|
||||||
|
|
||||||
// TODO: 2D shouldn't use AddPrim, draws in the wrong way
|
|
||||||
addPrim(&buffer->ot[p >> 2], poly);
|
addPrim(&buffer->ot[p >> 2], poly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -805,9 +803,9 @@ static void DrawTexturedQuads3D(int verticesCount, int startVertex) {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
static void DrawQuads(int verticesCount, int startVertex) {
|
static void DrawQuads(int verticesCount, int startVertex) {
|
||||||
if (rendering2D && gfx_format == VERTEX_FORMAT_TEXTURED) {
|
if (gfx_rendering2D && gfx_format == VERTEX_FORMAT_TEXTURED) {
|
||||||
DrawTexturedQuads2D(verticesCount, startVertex);
|
DrawTexturedQuads2D(verticesCount, startVertex);
|
||||||
} else if (rendering2D) {
|
} else if (gfx_rendering2D) {
|
||||||
DrawColouredQuads2D(verticesCount, startVertex);
|
DrawColouredQuads2D(verticesCount, startVertex);
|
||||||
} else if (gfx_format == VERTEX_FORMAT_TEXTURED) {
|
} else if (gfx_format == VERTEX_FORMAT_TEXTURED) {
|
||||||
DrawTexturedQuads3D(verticesCount, startVertex);
|
DrawTexturedQuads3D(verticesCount, startVertex);
|
||||||
@ -869,12 +867,12 @@ void Gfx_GetApiInfo(cc_string* info) {
|
|||||||
cc_bool Gfx_TryRestoreContext(void) { return true; }
|
cc_bool Gfx_TryRestoreContext(void) { return true; }
|
||||||
|
|
||||||
void Gfx_Begin2D(int width, int height) {
|
void Gfx_Begin2D(int width, int height) {
|
||||||
rendering2D = true;
|
gfx_rendering2D = true;
|
||||||
Gfx_SetAlphaBlending(true);
|
Gfx_SetAlphaBlending(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_End2D(void) {
|
void Gfx_End2D(void) {
|
||||||
rendering2D = false;
|
gfx_rendering2D = false;
|
||||||
Gfx_SetAlphaBlending(false);
|
Gfx_SetAlphaBlending(false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,446 +1,498 @@
|
|||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#if defined CC_BUILD_SATURN
|
#if defined CC_BUILD_SATURN
|
||||||
#include "_GraphicsBase.h"
|
#include "_GraphicsBase.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <yaul.h>
|
#include <yaul.h>
|
||||||
|
|
||||||
|
|
||||||
#define SCREEN_WIDTH 320
|
#define SCREEN_WIDTH 320
|
||||||
#define SCREEN_HEIGHT 224
|
#define SCREEN_HEIGHT 224
|
||||||
|
|
||||||
#define PRIMITIVE_DRAW_MODE_NORMAL (0)
|
#define PRIMITIVE_DRAW_MODE_NORMAL (0)
|
||||||
#define PRIMITIVE_DRAW_MODE_MESH (1)
|
#define PRIMITIVE_DRAW_MODE_MESH (1)
|
||||||
#define PRIMITIVE_DRAW_MODE_SHADOW (2)
|
#define PRIMITIVE_DRAW_MODE_SHADOW (2)
|
||||||
#define PRIMITIVE_DRAW_MODE_HALF_LUMINANCE (3)
|
#define PRIMITIVE_DRAW_MODE_HALF_LUMINANCE (3)
|
||||||
#define PRIMITIVE_DRAW_MODE_HALF_TRANSPARENT (4)
|
#define PRIMITIVE_DRAW_MODE_HALF_TRANSPARENT (4)
|
||||||
#define PRIMITIVE_DRAW_MODE_GOURAUD_SHADING (5)
|
#define PRIMITIVE_DRAW_MODE_GOURAUD_SHADING (5)
|
||||||
#define PRIMITIVE_DRAW_MODE_GOURAUD_HALF_LUM (6)
|
#define PRIMITIVE_DRAW_MODE_GOURAUD_HALF_LUM (6)
|
||||||
#define PRIMITIVE_DRAW_MODE_GOURAUD_HALF_TRANS (7)
|
#define PRIMITIVE_DRAW_MODE_GOURAUD_HALF_TRANS (7)
|
||||||
#define PRIMITIVE_DRAW_MODE_COUNT (8)
|
#define PRIMITIVE_DRAW_MODE_COUNT (8)
|
||||||
|
|
||||||
#define PRIMITIVE_COLOR RGB1555(1, 31, 0, 31)
|
#define PRIMITIVE_COLOR RGB1555(1, 31, 0, 31)
|
||||||
|
|
||||||
#define CMDS_COUNT 400
|
#define CMDS_COUNT 400
|
||||||
|
|
||||||
static PackedCol clear_color;
|
static PackedCol clear_color;
|
||||||
static vdp1_cmdt_t cmdts_all[CMDS_COUNT];
|
static vdp1_cmdt_t cmdts_all[CMDS_COUNT];
|
||||||
static int cmdts_count;
|
static int cmdts_count;
|
||||||
static vdp1_vram_partitions_t _vdp1_vram_partitions;
|
static vdp1_vram_partitions_t _vdp1_vram_partitions;
|
||||||
|
|
||||||
static vdp1_cmdt_t* NextPrimitive(void) {
|
static vdp1_cmdt_t* NextPrimitive(void) {
|
||||||
if (cmdts_count >= CMDS_COUNT) Logger_Abort("Too many VDP1 commands");
|
if (cmdts_count >= CMDS_COUNT) Logger_Abort("Too many VDP1 commands");
|
||||||
return &cmdts_all[cmdts_count++];
|
return &cmdts_all[cmdts_count++];
|
||||||
}
|
}
|
||||||
|
|
||||||
static vdp1_cmdt_draw_mode_t _primitive_draw_mode = {
|
static vdp1_cmdt_draw_mode_t _primitive_draw_mode = {
|
||||||
.raw = 0x0000
|
.raw = 0x0000
|
||||||
};
|
};
|
||||||
|
|
||||||
static int16_vec2_t clear_points[4];
|
static int16_vec2_t clear_points[4];
|
||||||
|
|
||||||
|
|
||||||
// TODO: how to use VDP1 erase ??
|
// TODO: how to use VDP1 erase ??
|
||||||
static void UpdateVDP1Env(void) {
|
static void UpdateVDP1Env(void) {
|
||||||
vdp1_env_t env;
|
vdp1_env_t env;
|
||||||
vdp1_env_default_init(&env);
|
vdp1_env_default_init(&env);
|
||||||
|
|
||||||
int R = PackedCol_R(clear_color);
|
int R = PackedCol_R(clear_color);
|
||||||
int G = PackedCol_G(clear_color);
|
int G = PackedCol_G(clear_color);
|
||||||
int B = PackedCol_B(clear_color);
|
int B = PackedCol_B(clear_color);
|
||||||
env.erase_color = RGB1555(1, R >> 3, G >> 3, B >> 3);
|
env.erase_color = RGB1555(1, R >> 3, G >> 3, B >> 3);
|
||||||
|
|
||||||
vdp1_env_set(&env);
|
vdp1_env_set(&env);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: should be SCREEN_WIDTH/2 instead ?
|
// TODO: should be SCREEN_WIDTH/2 instead ?
|
||||||
static void _primitive_init(void) {
|
static void _primitive_init(void) {
|
||||||
clear_points[0].x = 0;
|
clear_points[0].x = 0;
|
||||||
clear_points[0].y = SCREEN_WIDTH - 1;
|
clear_points[0].y = SCREEN_WIDTH - 1;
|
||||||
|
|
||||||
clear_points[1].x = SCREEN_WIDTH - 1;
|
clear_points[1].x = SCREEN_WIDTH - 1;
|
||||||
clear_points[1].y = SCREEN_HEIGHT - 1;
|
clear_points[1].y = SCREEN_HEIGHT - 1;
|
||||||
|
|
||||||
clear_points[2].x = SCREEN_HEIGHT - 1;
|
clear_points[2].x = SCREEN_HEIGHT - 1;
|
||||||
clear_points[2].y = 0;
|
clear_points[2].y = 0;
|
||||||
|
|
||||||
clear_points[3].x = 0;
|
clear_points[3].x = 0;
|
||||||
clear_points[3].y = 0;
|
clear_points[3].y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GfxResourceID white_square;
|
static GfxResourceID white_square;
|
||||||
void Gfx_RestoreState(void) {
|
void Gfx_RestoreState(void) {
|
||||||
InitDefaultResources();
|
InitDefaultResources();
|
||||||
|
|
||||||
// 2x2 dummy white texture
|
// 2x2 dummy white texture
|
||||||
struct Bitmap bmp;
|
struct Bitmap bmp;
|
||||||
BitmapCol pixels[4] = { BitmapColor_RGB(255, 0, 0), BITMAPCOLOR_WHITE, BITMAPCOLOR_WHITE, BITMAPCOLOR_WHITE };
|
BitmapCol pixels[4] = { BitmapColor_RGB(255, 0, 0), BITMAPCOLOR_WHITE, BITMAPCOLOR_WHITE, BITMAPCOLOR_WHITE };
|
||||||
Bitmap_Init(bmp, 2, 2, pixels);
|
Bitmap_Init(bmp, 2, 2, pixels);
|
||||||
white_square = Gfx_CreateTexture(&bmp, 0, false);
|
white_square = Gfx_CreateTexture(&bmp, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_FreeState(void) {
|
void Gfx_FreeState(void) {
|
||||||
FreeDefaultResources();
|
FreeDefaultResources();
|
||||||
Gfx_DeleteTexture(&white_square);
|
Gfx_DeleteTexture(&white_square);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_Create(void) {
|
void Gfx_Create(void) {
|
||||||
if (!Gfx.Created) {
|
if (!Gfx.Created) {
|
||||||
vdp1_vram_partitions_get(&_vdp1_vram_partitions);
|
vdp1_vram_partitions_get(&_vdp1_vram_partitions);
|
||||||
// TODO less ram for gourad base
|
// TODO less ram for gourad base
|
||||||
vdp2_scrn_back_color_set(VDP2_VRAM_ADDR(3, 0x01FFFE),
|
vdp2_scrn_back_color_set(VDP2_VRAM_ADDR(3, 0x01FFFE),
|
||||||
RGB1555(1, 0, 3, 15));
|
RGB1555(1, 0, 3, 15));
|
||||||
vdp2_sprite_priority_set(0, 6);
|
vdp2_sprite_priority_set(0, 6);
|
||||||
|
|
||||||
UpdateVDP1Env();
|
UpdateVDP1Env();
|
||||||
_primitive_init();
|
_primitive_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx.MaxTexWidth = 128;
|
Gfx.MinTexWidth = 8;
|
||||||
Gfx.MaxTexHeight = 128;
|
Gfx.MinTexHeight = 8;
|
||||||
Gfx.Created = true;
|
Gfx.MaxTexWidth = 128;
|
||||||
}
|
Gfx.MaxTexHeight = 128;
|
||||||
|
Gfx.Created = true;
|
||||||
void Gfx_Free(void) {
|
}
|
||||||
Gfx_FreeState();
|
|
||||||
}
|
void Gfx_Free(void) {
|
||||||
|
Gfx_FreeState();
|
||||||
|
}
|
||||||
/*########################################################################################################################*
|
|
||||||
*---------------------------------------------------------Textures--------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
/*########################################################################################################################*
|
||||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
*---------------------------------------------------------Textures--------------------------------------------------------*
|
||||||
return NULL;
|
*#########################################################################################################################*/
|
||||||
}
|
#define BGRA8_to_SATURN(src) \
|
||||||
|
((src[2] & 0xF8) >> 3) | ((src[1] & 0xF8) << 2) | ((src[0] & 0xF8) << 7) | ((src[3] & 0x80) << 8)
|
||||||
void Gfx_BindTexture(GfxResourceID texId) {
|
|
||||||
}
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
|
cc_uint16* tmp = Mem_TryAlloc(bmp->width * bmp->height, 2);
|
||||||
void Gfx_DeleteTexture(GfxResourceID* texId) {
|
if (!tmp) return NULL;
|
||||||
}
|
|
||||||
|
for (int y = 0; y < bmp->height; y++)
|
||||||
void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) {
|
{
|
||||||
// TODO
|
cc_uint32* src = bmp->scan0 + y * rowWidth;
|
||||||
}
|
cc_uint16* dst = tmp + y * bmp->width;
|
||||||
|
|
||||||
void Gfx_EnableMipmaps(void) { }
|
for (int x = 0; x < bmp->width; x++)
|
||||||
void Gfx_DisableMipmaps(void) { }
|
{
|
||||||
|
cc_uint8* color = (cc_uint8*)&src[x];
|
||||||
|
dst[x] = BGRA8_to_SATURN(color);
|
||||||
/*########################################################################################################################*
|
}
|
||||||
*------------------------------------------------------State management---------------------------------------------------*
|
}
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Gfx_SetFog(cc_bool enabled) { }
|
scu_dma_transfer(0, _vdp1_vram_partitions.texture_base, tmp, bmp->width * bmp->height * 2);
|
||||||
void Gfx_SetFogCol(PackedCol col) { }
|
scu_dma_transfer_wait(0);
|
||||||
void Gfx_SetFogDensity(float value) { }
|
Mem_Free(tmp);
|
||||||
void Gfx_SetFogEnd(float value) { }
|
return (void*)1;
|
||||||
void Gfx_SetFogMode(FogFunc func) { }
|
}
|
||||||
|
|
||||||
void Gfx_SetFaceCulling(cc_bool enabled) {
|
void Gfx_BindTexture(GfxResourceID texId) {
|
||||||
// TODO
|
}
|
||||||
}
|
|
||||||
|
void Gfx_DeleteTexture(GfxResourceID* texId) {
|
||||||
static void SetAlphaTest(cc_bool enabled) {
|
}
|
||||||
}
|
|
||||||
|
void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) {
|
||||||
static void SetAlphaBlend(cc_bool enabled) {
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_SetAlphaArgBlend(cc_bool enabled) { }
|
void Gfx_EnableMipmaps(void) { }
|
||||||
|
void Gfx_DisableMipmaps(void) { }
|
||||||
void Gfx_ClearBuffers(GfxBuffers buffers) {
|
|
||||||
}
|
|
||||||
|
/*########################################################################################################################*
|
||||||
void Gfx_ClearColor(PackedCol color) {
|
*------------------------------------------------------State management---------------------------------------------------*
|
||||||
if (color == clear_color) return;
|
*#########################################################################################################################*/
|
||||||
|
void Gfx_SetFog(cc_bool enabled) { }
|
||||||
clear_color = color;
|
void Gfx_SetFogCol(PackedCol col) { }
|
||||||
UpdateVDP1Env();
|
void Gfx_SetFogDensity(float value) { }
|
||||||
}
|
void Gfx_SetFogEnd(float value) { }
|
||||||
|
void Gfx_SetFogMode(FogFunc func) { }
|
||||||
void Gfx_SetDepthTest(cc_bool enabled) {
|
|
||||||
}
|
void Gfx_SetFaceCulling(cc_bool enabled) {
|
||||||
|
// TODO
|
||||||
void Gfx_SetDepthWrite(cc_bool enabled) {
|
}
|
||||||
// TODO
|
|
||||||
}
|
static void SetAlphaTest(cc_bool enabled) {
|
||||||
|
}
|
||||||
static void SetColorWrite(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
|
|
||||||
// TODO
|
static void SetAlphaBlend(cc_bool enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_DepthOnlyRendering(cc_bool depthOnly) {
|
void Gfx_SetAlphaArgBlend(cc_bool enabled) { }
|
||||||
cc_bool enabled = !depthOnly;
|
|
||||||
SetColorWrite(enabled & gfx_colorMask[0], enabled & gfx_colorMask[1],
|
void Gfx_ClearBuffers(GfxBuffers buffers) {
|
||||||
enabled & gfx_colorMask[2], enabled & gfx_colorMask[3]);
|
}
|
||||||
}
|
|
||||||
|
void Gfx_ClearColor(PackedCol color) {
|
||||||
|
if (color == clear_color) return;
|
||||||
/*########################################################################################################################*
|
|
||||||
*-------------------------------------------------------Index buffers-----------------------------------------------------*
|
clear_color = color;
|
||||||
*#########################################################################################################################*/
|
UpdateVDP1Env();
|
||||||
GfxResourceID Gfx_CreateIb2(int count, Gfx_FillIBFunc fillFunc, void* obj) {
|
}
|
||||||
return (void*)1;
|
|
||||||
}
|
void Gfx_SetDepthTest(cc_bool enabled) {
|
||||||
|
}
|
||||||
void Gfx_BindIb(GfxResourceID ib) { }
|
|
||||||
void Gfx_DeleteIb(GfxResourceID* ib) { }
|
void Gfx_SetDepthWrite(cc_bool enabled) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
/*########################################################################################################################*
|
|
||||||
*-------------------------------------------------------Vertex buffers----------------------------------------------------*
|
static void SetColorWrite(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
|
||||||
*#########################################################################################################################*/
|
// TODO
|
||||||
static void* gfx_vertices;
|
}
|
||||||
|
|
||||||
static GfxResourceID Gfx_AllocStaticVb(VertexFormat fmt, int count) {
|
void Gfx_DepthOnlyRendering(cc_bool depthOnly) {
|
||||||
return Mem_TryAlloc(count, strideSizes[fmt]);
|
cc_bool enabled = !depthOnly;
|
||||||
}
|
SetColorWrite(enabled & gfx_colorMask[0], enabled & gfx_colorMask[1],
|
||||||
|
enabled & gfx_colorMask[2], enabled & gfx_colorMask[3]);
|
||||||
void Gfx_BindVb(GfxResourceID vb) { gfx_vertices = vb; }
|
}
|
||||||
|
|
||||||
void Gfx_DeleteVb(GfxResourceID* vb) {
|
|
||||||
GfxResourceID data = *vb;
|
/*########################################################################################################################*
|
||||||
if (data) Mem_Free(data);
|
*-------------------------------------------------------Index buffers-----------------------------------------------------*
|
||||||
*vb = 0;
|
*#########################################################################################################################*/
|
||||||
}
|
GfxResourceID Gfx_CreateIb2(int count, Gfx_FillIBFunc fillFunc, void* obj) {
|
||||||
|
return (void*)1;
|
||||||
void* Gfx_LockVb(GfxResourceID vb, VertexFormat fmt, int count) {
|
}
|
||||||
return vb;
|
|
||||||
}
|
void Gfx_BindIb(GfxResourceID ib) { }
|
||||||
|
void Gfx_DeleteIb(GfxResourceID* ib) { }
|
||||||
void Gfx_UnlockVb(GfxResourceID vb) {
|
|
||||||
gfx_vertices = vb;
|
|
||||||
}
|
/*########################################################################################################################*
|
||||||
|
*-------------------------------------------------------Vertex buffers----------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
static GfxResourceID Gfx_AllocDynamicVb(VertexFormat fmt, int maxVertices) {
|
static void* gfx_vertices;
|
||||||
return Mem_TryAlloc(maxVertices, strideSizes[fmt]);
|
|
||||||
}
|
static GfxResourceID Gfx_AllocStaticVb(VertexFormat fmt, int count) {
|
||||||
|
return Mem_TryAlloc(count, strideSizes[fmt]);
|
||||||
void Gfx_BindDynamicVb(GfxResourceID vb) { Gfx_BindVb(vb); }
|
}
|
||||||
|
|
||||||
void* Gfx_LockDynamicVb(GfxResourceID vb, VertexFormat fmt, int count) {
|
void Gfx_BindVb(GfxResourceID vb) { gfx_vertices = vb; }
|
||||||
return vb;
|
|
||||||
}
|
void Gfx_DeleteVb(GfxResourceID* vb) {
|
||||||
|
GfxResourceID data = *vb;
|
||||||
void Gfx_UnlockDynamicVb(GfxResourceID vb) {
|
if (data) Mem_Free(data);
|
||||||
gfx_vertices = vb;
|
*vb = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_DeleteDynamicVb(GfxResourceID* vb) { Gfx_DeleteVb(vb); }
|
void* Gfx_LockVb(GfxResourceID vb, VertexFormat fmt, int count) {
|
||||||
|
return vb;
|
||||||
|
}
|
||||||
/*########################################################################################################################*
|
|
||||||
*---------------------------------------------------------Matrices--------------------------------------------------------*
|
void Gfx_UnlockVb(GfxResourceID vb) {
|
||||||
*#########################################################################################################################*/
|
gfx_vertices = vb;
|
||||||
static struct Matrix _view, _proj, mvp;
|
}
|
||||||
|
|
||||||
void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
|
|
||||||
if (type == MATRIX_VIEW) _view = *matrix;
|
static GfxResourceID Gfx_AllocDynamicVb(VertexFormat fmt, int maxVertices) {
|
||||||
if (type == MATRIX_PROJECTION) _proj = *matrix;
|
return Mem_TryAlloc(maxVertices, strideSizes[fmt]);
|
||||||
|
}
|
||||||
Matrix_Mul(&mvp, &_view, &_proj);
|
|
||||||
}
|
void Gfx_BindDynamicVb(GfxResourceID vb) { Gfx_BindVb(vb); }
|
||||||
|
|
||||||
void Gfx_LoadIdentityMatrix(MatrixType type) {
|
void* Gfx_LockDynamicVb(GfxResourceID vb, VertexFormat fmt, int count) {
|
||||||
Gfx_LoadMatrix(type, &Matrix_Identity);
|
return vb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_EnableTextureOffset(float x, float y) {
|
void Gfx_UnlockDynamicVb(GfxResourceID vb) {
|
||||||
// TODO
|
gfx_vertices = vb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_DisableTextureOffset(void) {
|
void Gfx_DeleteDynamicVb(GfxResourceID* vb) { Gfx_DeleteVb(vb); }
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
/*########################################################################################################################*
|
||||||
void Gfx_CalcOrthoMatrix(struct Matrix* matrix, float width, float height, float zNear, float zFar) {
|
*---------------------------------------------------------Matrices--------------------------------------------------------*
|
||||||
/* Source https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dxmatrixorthooffcenterrh */
|
*#########################################################################################################################*/
|
||||||
/* The simplified calculation below uses: L = 0, R = width, T = 0, B = height */
|
static struct Matrix _view, _proj, mvp;
|
||||||
/* NOTE: This calculation is shared with Direct3D 11 backend */
|
|
||||||
*matrix = Matrix_Identity;
|
void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
|
||||||
|
if (type == MATRIX_VIEW) _view = *matrix;
|
||||||
matrix->row1.x = 2.0f / width;
|
if (type == MATRIX_PROJECTION) _proj = *matrix;
|
||||||
matrix->row2.y = -2.0f / height;
|
|
||||||
matrix->row3.z = 1.0f / (zNear - zFar);
|
Matrix_Mul(&mvp, &_view, &_proj);
|
||||||
|
}
|
||||||
matrix->row4.x = -1.0f;
|
|
||||||
matrix->row4.y = 1.0f;
|
void Gfx_LoadIdentityMatrix(MatrixType type) {
|
||||||
matrix->row4.z = zNear / (zNear - zFar);
|
Gfx_LoadMatrix(type, &Matrix_Identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float Cotangent(float x) { return Math_CosF(x) / Math_SinF(x); }
|
void Gfx_EnableTextureOffset(float x, float y) {
|
||||||
void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, float zFar) {
|
// TODO
|
||||||
float zNear = 0.01f;
|
}
|
||||||
/* Source https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dxmatrixperspectivefovrh */
|
|
||||||
float c = Cotangent(0.5f * fov);
|
void Gfx_DisableTextureOffset(void) {
|
||||||
*matrix = Matrix_Identity;
|
// TODO
|
||||||
|
}
|
||||||
matrix->row1.x = c / aspect;
|
|
||||||
matrix->row2.y = c;
|
void Gfx_CalcOrthoMatrix(struct Matrix* matrix, float width, float height, float zNear, float zFar) {
|
||||||
matrix->row3.z = zFar / (zNear - zFar);
|
/* Source https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dxmatrixorthooffcenterrh */
|
||||||
matrix->row3.w = -1.0f;
|
/* The simplified calculation below uses: L = 0, R = width, T = 0, B = height */
|
||||||
matrix->row4.z = (zNear * zFar) / (zNear - zFar);
|
/* NOTE: This calculation is shared with Direct3D 11 backend */
|
||||||
matrix->row4.w = 0.0f;
|
*matrix = Matrix_Identity;
|
||||||
}
|
|
||||||
|
matrix->row1.x = 2.0f / width;
|
||||||
|
matrix->row2.y = -2.0f / height;
|
||||||
/*########################################################################################################################*
|
matrix->row3.z = 1.0f / (zNear - zFar);
|
||||||
*---------------------------------------------------------Rendering-------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
matrix->row4.x = -1.0f;
|
||||||
void Gfx_SetVertexFormat(VertexFormat fmt) {
|
matrix->row4.y = 1.0f;
|
||||||
gfx_format = fmt;
|
matrix->row4.z = zNear / (zNear - zFar);
|
||||||
gfx_stride = strideSizes[fmt];
|
}
|
||||||
}
|
|
||||||
|
static float Cotangent(float x) { return Math_CosF(x) / Math_SinF(x); }
|
||||||
void Gfx_DrawVb_Lines(int verticesCount) {
|
void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, float zFar) {
|
||||||
|
float zNear = 0.01f;
|
||||||
}
|
/* Source https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dxmatrixperspectivefovrh */
|
||||||
|
float c = Cotangent(0.5f * fov);
|
||||||
static void Transform(Vec3* result, struct VertexTextured* a, const struct Matrix* mat) {
|
*matrix = Matrix_Identity;
|
||||||
/* a could be pointing to result - therefore can't directly assign X/Y/Z */
|
|
||||||
float x = a->x * mat->row1.x + a->y * mat->row2.x + a->z * mat->row3.x + mat->row4.x;
|
matrix->row1.x = c / aspect;
|
||||||
float y = a->x * mat->row1.y + a->y * mat->row2.y + a->z * mat->row3.y + mat->row4.y;
|
matrix->row2.y = c;
|
||||||
float z = a->x * mat->row1.z + a->y * mat->row2.z + a->z * mat->row3.z + mat->row4.z;
|
matrix->row3.z = zFar / (zNear - zFar);
|
||||||
float w = a->x * mat->row1.w + a->y * mat->row2.w + a->z * mat->row3.w + mat->row4.w;
|
matrix->row3.w = -1.0f;
|
||||||
|
matrix->row4.z = (zNear * zFar) / (zNear - zFar);
|
||||||
result->x = (x/w) * (320/2);
|
matrix->row4.w = 0.0f;
|
||||||
result->y = (y/w) * -(224/2);
|
}
|
||||||
result->z = (z/w) * 1024;
|
|
||||||
}
|
|
||||||
|
/*########################################################################################################################*
|
||||||
#define IsPointCulled(vec) vec.x < -10000 || vec.x > 10000 || vec.y < -10000 || vec.y > 10000 || vec.z < 0 || vec.z > 1024
|
*---------------------------------------------------------Rendering-------------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
static void DrawTexturedQuads(int verticesCount, int startVertex) {
|
void Gfx_SetVertexFormat(VertexFormat fmt) {
|
||||||
for (int i = 0; i < verticesCount; i += 4)
|
gfx_format = fmt;
|
||||||
{
|
gfx_stride = strideSizes[fmt];
|
||||||
struct VertexTextured* v = (struct VertexTextured*)gfx_vertices + startVertex + i;
|
}
|
||||||
|
|
||||||
Vec3 coords[4];
|
void Gfx_DrawVb_Lines(int verticesCount) {
|
||||||
Transform(&coords[0], &v[0], &mvp);
|
|
||||||
Transform(&coords[1], &v[1], &mvp);
|
}
|
||||||
Transform(&coords[2], &v[2], &mvp);
|
|
||||||
Transform(&coords[3], &v[3], &mvp);
|
static void Transform(Vec3* result, struct VertexTextured* a, const struct Matrix* mat) {
|
||||||
|
/* a could be pointing to result - therefore can't directly assign X/Y/Z */
|
||||||
int16_vec2_t points[4];
|
float x = a->x * mat->row1.x + a->y * mat->row2.x + a->z * mat->row3.x + mat->row4.x;
|
||||||
points[0].x = coords[0].x; points[0].y = coords[0].y;
|
float y = a->x * mat->row1.y + a->y * mat->row2.y + a->z * mat->row3.y + mat->row4.y;
|
||||||
points[1].x = coords[1].x; points[1].y = coords[1].y;
|
float z = a->x * mat->row1.z + a->y * mat->row2.z + a->z * mat->row3.z + mat->row4.z;
|
||||||
points[2].x = coords[2].x; points[2].y = coords[2].y;
|
float w = a->x * mat->row1.w + a->y * mat->row2.w + a->z * mat->row3.w + mat->row4.w;
|
||||||
points[3].x = coords[3].x; points[3].y = coords[3].y;
|
|
||||||
|
result->x = (x/w) * (SCREEN_WIDTH / 2);
|
||||||
if (IsPointCulled(coords[0])) continue;
|
result->y = (y/w) * -(SCREEN_HEIGHT / 2);
|
||||||
if (IsPointCulled(coords[1])) continue;
|
result->z = (z/w) * 1024;
|
||||||
if (IsPointCulled(coords[2])) continue;
|
}
|
||||||
if (IsPointCulled(coords[3])) continue;
|
|
||||||
|
#define IsPointCulled(vec) vec.x < -10000 || vec.x > 10000 || vec.y < -10000 || vec.y > 10000 || vec.z < 0 || vec.z > 1024
|
||||||
int R = PackedCol_R(v->Col);
|
|
||||||
int G = PackedCol_G(v->Col);
|
static void DrawTexturedQuads2D(int verticesCount, int startVertex) {
|
||||||
int B = PackedCol_B(v->Col);
|
for (int i = 0; i < verticesCount; i += 4)
|
||||||
|
{
|
||||||
vdp1_cmdt_t* cmd;
|
struct VertexTextured* v = (struct VertexTextured*)gfx_vertices + startVertex + i;
|
||||||
|
|
||||||
cmd = NextPrimitive();
|
int16_vec2_t points[4];
|
||||||
vdp1_cmdt_polygon_set(cmd);
|
points[0].x = (int)v[0].x - SCREEN_WIDTH / 2; points[0].y = (int)v[0].y - SCREEN_HEIGHT / 2;
|
||||||
vdp1_cmdt_color_set(cmd, RGB1555(1, R >> 3, G >> 3, B >> 3));
|
points[1].x = (int)v[1].x - SCREEN_WIDTH / 2; points[1].y = (int)v[1].y - SCREEN_HEIGHT / 2;
|
||||||
vdp1_cmdt_draw_mode_set(cmd, _primitive_draw_mode);
|
points[2].x = (int)v[2].x - SCREEN_WIDTH / 2; points[2].y = (int)v[2].y - SCREEN_HEIGHT / 2;
|
||||||
vdp1_cmdt_vtx_set(cmd, points);
|
points[3].x = (int)v[3].x - SCREEN_WIDTH / 2; points[3].y = (int)v[3].y - SCREEN_HEIGHT / 2;
|
||||||
}
|
|
||||||
}
|
int R = PackedCol_R(v->Col);
|
||||||
|
int G = PackedCol_G(v->Col);
|
||||||
void Gfx_DrawVb_IndexedTris_Range(int verticesCount, int startVertex) {
|
int B = PackedCol_B(v->Col);
|
||||||
if (gfx_format == VERTEX_FORMAT_TEXTURED) {
|
|
||||||
DrawTexturedQuads(verticesCount, startVertex);
|
vdp1_cmdt_t* cmd;
|
||||||
}
|
|
||||||
}
|
cmd = NextPrimitive();
|
||||||
|
vdp1_cmdt_polygon_set(cmd);
|
||||||
void Gfx_DrawVb_IndexedTris(int verticesCount) {
|
vdp1_cmdt_color_set(cmd, RGB1555(1, R >> 3, G >> 3, B >> 3));
|
||||||
if (gfx_format == VERTEX_FORMAT_TEXTURED) {
|
vdp1_cmdt_draw_mode_set(cmd, _primitive_draw_mode);
|
||||||
DrawTexturedQuads(verticesCount, 0);
|
vdp1_cmdt_vtx_set(cmd, points);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
|
static void DrawTexturedQuads3D(int verticesCount, int startVertex) {
|
||||||
DrawTexturedQuads(verticesCount, startVertex);
|
for (int i = 0; i < verticesCount; i += 4)
|
||||||
}
|
{
|
||||||
|
struct VertexTextured* v = (struct VertexTextured*)gfx_vertices + startVertex + i;
|
||||||
|
|
||||||
/*########################################################################################################################*
|
Vec3 coords[4];
|
||||||
*---------------------------------------------------------Other/Misc------------------------------------------------------*
|
Transform(&coords[0], &v[0], &mvp);
|
||||||
*#########################################################################################################################*/
|
Transform(&coords[1], &v[1], &mvp);
|
||||||
cc_result Gfx_TakeScreenshot(struct Stream* output) {
|
Transform(&coords[2], &v[2], &mvp);
|
||||||
return ERR_NOT_SUPPORTED;
|
Transform(&coords[3], &v[3], &mvp);
|
||||||
}
|
|
||||||
|
int16_vec2_t points[4];
|
||||||
cc_bool Gfx_WarnIfNecessary(void) {
|
points[0].x = coords[0].x; points[0].y = coords[0].y;
|
||||||
return false;
|
points[1].x = coords[1].x; points[1].y = coords[1].y;
|
||||||
}
|
points[2].x = coords[2].x; points[2].y = coords[2].y;
|
||||||
|
points[3].x = coords[3].x; points[3].y = coords[3].y;
|
||||||
void Gfx_BeginFrame(void) {
|
|
||||||
Platform_LogConst("FRAME BEG");
|
if (IsPointCulled(coords[0])) continue;
|
||||||
cmdts_count = 0;
|
if (IsPointCulled(coords[1])) continue;
|
||||||
|
if (IsPointCulled(coords[2])) continue;
|
||||||
static const int16_vec2_t system_clip_coord = { SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 };
|
if (IsPointCulled(coords[3])) continue;
|
||||||
static const int16_vec2_t local_coord_center = { SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 };
|
|
||||||
|
int R = PackedCol_R(v->Col);
|
||||||
vdp1_cmdt_t* cmd;
|
int G = PackedCol_G(v->Col);
|
||||||
|
int B = PackedCol_B(v->Col);
|
||||||
cmd = NextPrimitive();
|
|
||||||
vdp1_cmdt_system_clip_coord_set(cmd);
|
vdp1_cmdt_t* cmd;
|
||||||
vdp1_cmdt_vtx_system_clip_coord_set(cmd, system_clip_coord);
|
|
||||||
|
cmd = NextPrimitive();
|
||||||
cmd = NextPrimitive();
|
vdp1_cmdt_polygon_set(cmd);
|
||||||
vdp1_cmdt_local_coord_set(cmd);
|
vdp1_cmdt_color_set(cmd, RGB1555(1, R >> 3, G >> 3, B >> 3));
|
||||||
vdp1_cmdt_vtx_local_coord_set(cmd, local_coord_center);
|
vdp1_cmdt_draw_mode_set(cmd, _primitive_draw_mode);
|
||||||
|
vdp1_cmdt_vtx_set(cmd, points);
|
||||||
int R = PackedCol_R(clear_color);
|
}
|
||||||
int G = PackedCol_G(clear_color);
|
}
|
||||||
int B = PackedCol_B(clear_color);
|
|
||||||
|
void Gfx_DrawVb_IndexedTris_Range(int verticesCount, int startVertex) {
|
||||||
cmd = NextPrimitive();
|
if (gfx_rendering2D && gfx_format == VERTEX_FORMAT_TEXTURED) {
|
||||||
vdp1_cmdt_polygon_set(cmd);
|
DrawTexturedQuads2D(verticesCount, startVertex);
|
||||||
vdp1_cmdt_color_set(cmd, RGB1555(1, R >> 3, G >> 3, B >> 3)); // TODO VDP1 erase
|
} else if (gfx_format == VERTEX_FORMAT_TEXTURED) {
|
||||||
vdp1_cmdt_draw_mode_set(cmd, _primitive_draw_mode);
|
DrawTexturedQuads3D(verticesCount, startVertex);
|
||||||
vdp1_cmdt_vtx_set(cmd, clear_points);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_EndFrame(void) {
|
void Gfx_DrawVb_IndexedTris(int verticesCount) {
|
||||||
Platform_LogConst("FRAME END");
|
if (gfx_rendering2D && gfx_format == VERTEX_FORMAT_TEXTURED) {
|
||||||
vdp1_cmdt_t* cmd;
|
DrawTexturedQuads2D(verticesCount, 0);
|
||||||
|
} else if (gfx_format == VERTEX_FORMAT_TEXTURED) {
|
||||||
cmd = NextPrimitive();
|
DrawTexturedQuads3D(verticesCount, 0);
|
||||||
vdp1_cmdt_end_set(cmd);
|
}
|
||||||
|
}
|
||||||
vdp1_cmdt_list_t cmdt_list;
|
|
||||||
cmdt_list.cmdts = cmdts_all;
|
void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
|
||||||
cmdt_list.count = cmdts_count;
|
DrawTexturedQuads3D(verticesCount, startVertex);
|
||||||
vdp1_sync_cmdt_list_put(&cmdt_list, 0);
|
}
|
||||||
|
|
||||||
vdp1_sync_render();
|
|
||||||
vdp1_sync();
|
/*########################################################################################################################*
|
||||||
vdp2_sync();
|
*---------------------------------------------------------Other/Misc------------------------------------------------------*
|
||||||
vdp2_sync_wait();
|
*#########################################################################################################################*/
|
||||||
|
cc_result Gfx_TakeScreenshot(struct Stream* output) {
|
||||||
if (gfx_minFrameMs) LimitFPS();
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_SetFpsLimit(cc_bool vsync, float minFrameMs) {
|
cc_bool Gfx_WarnIfNecessary(void) {
|
||||||
gfx_minFrameMs = minFrameMs;
|
return false;
|
||||||
gfx_vsync = vsync;
|
}
|
||||||
}
|
|
||||||
|
void Gfx_BeginFrame(void) {
|
||||||
void Gfx_OnWindowResize(void) {
|
Platform_LogConst("FRAME BEG");
|
||||||
// TODO
|
cmdts_count = 0;
|
||||||
}
|
|
||||||
|
static const int16_vec2_t system_clip_coord = { SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 };
|
||||||
void Gfx_SetViewport(int x, int y, int w, int h) { }
|
static const int16_vec2_t local_coord_center = { SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 };
|
||||||
|
|
||||||
void Gfx_GetApiInfo(cc_string* info) {
|
vdp1_cmdt_t* cmd;
|
||||||
String_AppendConst(info, "-- Using Saturn --\n");
|
|
||||||
PrintMaxTextureInfo(info);
|
cmd = NextPrimitive();
|
||||||
}
|
vdp1_cmdt_system_clip_coord_set(cmd);
|
||||||
|
vdp1_cmdt_vtx_system_clip_coord_set(cmd, system_clip_coord);
|
||||||
cc_bool Gfx_TryRestoreContext(void) { return true; }
|
|
||||||
#endif
|
cmd = NextPrimitive();
|
||||||
|
vdp1_cmdt_local_coord_set(cmd);
|
||||||
|
vdp1_cmdt_vtx_local_coord_set(cmd, local_coord_center);
|
||||||
|
|
||||||
|
int R = PackedCol_R(clear_color);
|
||||||
|
int G = PackedCol_G(clear_color);
|
||||||
|
int B = PackedCol_B(clear_color);
|
||||||
|
|
||||||
|
cmd = NextPrimitive();
|
||||||
|
vdp1_cmdt_polygon_set(cmd);
|
||||||
|
vdp1_cmdt_color_set(cmd, RGB1555(1, R >> 3, G >> 3, B >> 3)); // TODO VDP1 erase
|
||||||
|
vdp1_cmdt_draw_mode_set(cmd, _primitive_draw_mode);
|
||||||
|
vdp1_cmdt_vtx_set(cmd, clear_points);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gfx_EndFrame(void) {
|
||||||
|
Platform_LogConst("FRAME END");
|
||||||
|
vdp1_cmdt_t* cmd;
|
||||||
|
|
||||||
|
cmd = NextPrimitive();
|
||||||
|
vdp1_cmdt_end_set(cmd);
|
||||||
|
|
||||||
|
vdp1_cmdt_list_t cmdt_list;
|
||||||
|
cmdt_list.cmdts = cmdts_all;
|
||||||
|
cmdt_list.count = cmdts_count;
|
||||||
|
vdp1_sync_cmdt_list_put(&cmdt_list, 0);
|
||||||
|
|
||||||
|
vdp1_sync_render();
|
||||||
|
vdp1_sync();
|
||||||
|
vdp2_sync();
|
||||||
|
vdp2_sync_wait();
|
||||||
|
|
||||||
|
if (gfx_minFrameMs) LimitFPS();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gfx_SetFpsLimit(cc_bool vsync, float minFrameMs) {
|
||||||
|
gfx_minFrameMs = minFrameMs;
|
||||||
|
gfx_vsync = vsync;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gfx_OnWindowResize(void) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gfx_SetViewport(int x, int y, int w, int h) { }
|
||||||
|
|
||||||
|
void Gfx_GetApiInfo(cc_string* info) {
|
||||||
|
String_AppendConst(info, "-- Using Saturn --\n");
|
||||||
|
PrintMaxTextureInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_bool Gfx_TryRestoreContext(void) { return true; }
|
||||||
|
#endif
|
||||||
|
16
src/Input.c
16
src/Input.c
@ -215,8 +215,13 @@ static const char* const storageNames[INPUT_COUNT] = {
|
|||||||
"Keypad0", "Keypad1", "Keypad2", "Keypad3", "Keypad4",
|
"Keypad0", "Keypad1", "Keypad2", "Keypad3", "Keypad4",
|
||||||
"Keypad5", "Keypad6", "Keypad7", "Keypad8", "Keypad9",
|
"Keypad5", "Keypad6", "Keypad7", "Keypad8", "Keypad9",
|
||||||
"KeypadDivide", "KeypadMultiply", "KeypadSubtract",
|
"KeypadDivide", "KeypadMultiply", "KeypadSubtract",
|
||||||
"KeypadAdd", "KeypadDecimal", "KeypadEnter",
|
"KeypadAdd", "KeypadDecimal", "KeypadEnter",
|
||||||
"XButton1", "XButton2", "LeftMouse", "RightMouse", "MiddleMouse",
|
|
||||||
|
"VolumeMute", "VolumeUp", "VolumeDown",
|
||||||
|
"MediaNext", "MediaPrev", "MediaPlay", "MediaStop",
|
||||||
|
|
||||||
|
"XButton1", "XButton2", "XButton3", "XButton4", "XButton5", "XButton6",
|
||||||
|
"LeftMouse", "RightMouse", "MiddleMouse",
|
||||||
Pad_Names
|
Pad_Names
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -239,7 +244,12 @@ const char* const Input_DisplayNames[INPUT_COUNT] = {
|
|||||||
"NUMPAD5", "NUMPAD6", "NUMPAD7", "NUMPAD8", "NUMPAD9",
|
"NUMPAD5", "NUMPAD6", "NUMPAD7", "NUMPAD8", "NUMPAD9",
|
||||||
"DIVIDE", "MULTIPLY", "SUBTRACT",
|
"DIVIDE", "MULTIPLY", "SUBTRACT",
|
||||||
"ADD", "DECIMAL", "NUMPADENTER",
|
"ADD", "DECIMAL", "NUMPADENTER",
|
||||||
"XBUTTON1", "XBUTTON2", "LMOUSE", "RMOUSE", "MMOUSE",
|
|
||||||
|
"VOLUMEMUTE", "VOLUMEUP", "VOLUMEDOWN",
|
||||||
|
"MEDIANEXT", "MEDIAPREV", "MEDIAPLAY", "MEDIASTOP",
|
||||||
|
|
||||||
|
"XBUTTON1", "XBUTTON2", "XBUTTON3", "XBUTTON4", "XBUTTON5", "XBUTTON6",
|
||||||
|
"LMOUSE", "RMOUSE", "MMOUSE",
|
||||||
Pad_Names
|
Pad_Names
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,9 +41,13 @@ enum InputButtons {
|
|||||||
CCKEY_KP5, CCKEY_KP6, CCKEY_KP7, CCKEY_KP8, CCKEY_KP9,
|
CCKEY_KP5, CCKEY_KP6, CCKEY_KP7, CCKEY_KP8, CCKEY_KP9,
|
||||||
CCKEY_KP_DIVIDE, CCKEY_KP_MULTIPLY, CCKEY_KP_MINUS,
|
CCKEY_KP_DIVIDE, CCKEY_KP_MULTIPLY, CCKEY_KP_MINUS,
|
||||||
CCKEY_KP_PLUS, CCKEY_KP_DECIMAL, CCKEY_KP_ENTER,
|
CCKEY_KP_PLUS, CCKEY_KP_DECIMAL, CCKEY_KP_ENTER,
|
||||||
|
|
||||||
|
CCKEY_VOLUME_MUTE, CCKEY_VOLUME_UP, CCKEY_VOLUME_DOWN,
|
||||||
|
CCKEY_MEDIA_NEXT, CCKEY_MEDIA_PREV, CCKEY_MEDIA_PLAY, CCKEY_MEDIA_STOP,
|
||||||
|
|
||||||
/* NOTE: RMOUSE must be before MMOUSE for PlayerClick compatibility */
|
/* NOTE: RMOUSE must be before MMOUSE for PlayerClick compatibility */
|
||||||
CCMOUSE_X1, CCMOUSE_X2, CCMOUSE_L, CCMOUSE_R, CCMOUSE_M,
|
CCMOUSE_X1, CCMOUSE_X2, CCMOUSE_X3, CCMOUSE_X4, CCMOUSE_X5, CCMOUSE_X6,
|
||||||
|
CCMOUSE_L, CCMOUSE_R, CCMOUSE_M,
|
||||||
|
|
||||||
CCPAD_A, CCPAD_B, CCPAD_X, CCPAD_Y, CCPAD_L, CCPAD_R, CCPAD_Z,
|
CCPAD_A, CCPAD_B, CCPAD_X, CCPAD_Y, CCPAD_L, CCPAD_R, CCPAD_Z,
|
||||||
CCPAD_LEFT, CCPAD_RIGHT, CCPAD_UP, CCPAD_DOWN,
|
CCPAD_LEFT, CCPAD_RIGHT, CCPAD_UP, CCPAD_DOWN,
|
||||||
|
12
src/Menus.c
12
src/Menus.c
@ -516,7 +516,7 @@ static void PauseScreen_CheckHacksAllowed(void* screen) {
|
|||||||
struct PauseScreen* s = (struct PauseScreen*)screen;
|
struct PauseScreen* s = (struct PauseScreen*)screen;
|
||||||
if (Gui.ClassicMenu) return;
|
if (Gui.ClassicMenu) return;
|
||||||
|
|
||||||
Widget_SetDisabled(&s->btns[4],
|
Widget_SetDisabled(&s->btns[1],
|
||||||
!Entities.CurPlayer->Hacks.CanAnyHacks); /* select texture pack */
|
!Entities.CurPlayer->Hacks.CanAnyHacks); /* select texture pack */
|
||||||
s->dirty = true;
|
s->dirty = true;
|
||||||
}
|
}
|
||||||
@ -543,11 +543,11 @@ static void PauseScreen_Init(void* screen) {
|
|||||||
struct PauseScreen* s = (struct PauseScreen*)screen;
|
struct PauseScreen* s = (struct PauseScreen*)screen;
|
||||||
static const struct SimpleButtonDesc descs[] = {
|
static const struct SimpleButtonDesc descs[] = {
|
||||||
{ -160, -50, "Options...", Menu_SwitchOptions },
|
{ -160, -50, "Options...", Menu_SwitchOptions },
|
||||||
|
{ -160, 0, "Change texture pack...", Menu_SwitchTexPacks },
|
||||||
|
{ -160, 50, "Hotkeys...", Menu_SwitchHotkeys },
|
||||||
{ 160, -50, "Generate new level...", Menu_SwitchGenLevel },
|
{ 160, -50, "Generate new level...", Menu_SwitchGenLevel },
|
||||||
{ 160, 0, "Load level...", Menu_SwitchLoadLevel },
|
{ 160, 0, "Load level...", Menu_SwitchLoadLevel },
|
||||||
{ 160, 50, "Save level...", Menu_SwitchSaveLevel },
|
{ 160, 50, "Save level...", Menu_SwitchSaveLevel }
|
||||||
{ -160, 0, "Change texture pack...", Menu_SwitchTexPacks },
|
|
||||||
{ -160, 50, "Hotkeys...", Menu_SwitchHotkeys }
|
|
||||||
};
|
};
|
||||||
s->widgets = pause_widgets;
|
s->widgets = pause_widgets;
|
||||||
s->numWidgets = 0;
|
s->numWidgets = 0;
|
||||||
@ -561,8 +561,8 @@ static void PauseScreen_Init(void* screen) {
|
|||||||
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
|
s->maxVertices = Screen_CalcDefaultMaxVertices(s);
|
||||||
|
|
||||||
if (Server.IsSinglePlayer) return;
|
if (Server.IsSinglePlayer) return;
|
||||||
s->btns[1].flags = WIDGET_FLAG_DISABLED;
|
s->btns[3].flags = WIDGET_FLAG_DISABLED;
|
||||||
s->btns[2].flags = WIDGET_FLAG_DISABLED;
|
s->btns[5].flags = WIDGET_FLAG_DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PauseScreen_Free(void* screen) {
|
static void PauseScreen_Free(void* screen) {
|
||||||
|
@ -64,13 +64,17 @@ cc_uint64 Stopwatch_Measure(void) {
|
|||||||
|
|
||||||
cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
||||||
if (end < beg) return 0;
|
if (end < beg) return 0;
|
||||||
return (end - beg); // TODO measure time
|
cc_uint32 delta = end - beg;
|
||||||
|
|
||||||
|
// TODO still wrong?? and overflows?? and PAL detection ???
|
||||||
|
return (delta * 1000) / CPU_FRT_NTSC_320_128_COUNT_1MS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ovf_handler(void) { overflow_count++; }
|
static void ovf_handler(void) { overflow_count++; }
|
||||||
|
|
||||||
static void Stopwatch_Init(void) {
|
static void Stopwatch_Init(void) {
|
||||||
cpu_frt_init(CPU_FRT_CLOCK_DIV_8);
|
//cpu_frt_init(CPU_FRT_CLOCK_DIV_8);
|
||||||
|
cpu_frt_init(CPU_FRT_CLOCK_DIV_128);
|
||||||
cpu_frt_ovi_set(ovf_handler);
|
cpu_frt_ovi_set(ovf_handler);
|
||||||
|
|
||||||
cpu_frt_interrupt_priority_set(15);
|
cpu_frt_interrupt_priority_set(15);
|
||||||
|
@ -189,6 +189,15 @@ static int MapNativeKey(SDL_Keycode k) {
|
|||||||
case SDLK_RSHIFT: return CCKEY_RSHIFT;
|
case SDLK_RSHIFT: return CCKEY_RSHIFT;
|
||||||
case SDLK_RALT: return CCKEY_RALT;
|
case SDLK_RALT: return CCKEY_RALT;
|
||||||
case SDLK_RGUI: return CCKEY_RWIN;
|
case SDLK_RGUI: return CCKEY_RWIN;
|
||||||
|
|
||||||
|
case SDLK_AUDIONEXT: return CCKEY_MEDIA_NEXT;
|
||||||
|
case SDLK_AUDIOPREV: return CCKEY_MEDIA_PREV;
|
||||||
|
case SDLK_AUDIOPLAY: return CCKEY_MEDIA_PLAY;
|
||||||
|
case SDLK_AUDIOSTOP: return CCKEY_MEDIA_STOP;
|
||||||
|
|
||||||
|
case SDLK_AUDIOMUTE: return CCKEY_VOLUME_MUTE;
|
||||||
|
case SDLK_VOLUMEDOWN: return CCKEY_VOLUME_DOWN;
|
||||||
|
case SDLK_VOLUMEUP: return CCKEY_VOLUME_UP;
|
||||||
}
|
}
|
||||||
return INPUT_NONE;
|
return INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
@ -176,6 +176,15 @@ static int MapNativeKey(SDL_Keycode k) {
|
|||||||
case SDLK_RSHIFT: return CCKEY_RSHIFT;
|
case SDLK_RSHIFT: return CCKEY_RSHIFT;
|
||||||
case SDLK_RALT: return CCKEY_RALT;
|
case SDLK_RALT: return CCKEY_RALT;
|
||||||
case SDLK_RGUI: return CCKEY_RWIN;
|
case SDLK_RGUI: return CCKEY_RWIN;
|
||||||
|
|
||||||
|
case SDLK_AUDIONEXT: return CCKEY_MEDIA_NEXT;
|
||||||
|
case SDLK_AUDIOPREV: return CCKEY_MEDIA_PREV;
|
||||||
|
case SDLK_AUDIOPLAY: return CCKEY_MEDIA_PLAY;
|
||||||
|
case SDLK_AUDIOSTOP: return CCKEY_MEDIA_STOP;
|
||||||
|
|
||||||
|
case SDLK_AUDIOMUTE: return CCKEY_VOLUME_MUTE;
|
||||||
|
case SDLK_VOLUMEDOWN: return CCKEY_VOLUME_DOWN;
|
||||||
|
case SDLK_VOLUMEUP: return CCKEY_VOLUME_UP;
|
||||||
}
|
}
|
||||||
return INPUT_NONE;
|
return INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#define SCREEN_HEIGHT 224
|
#define SCREEN_HEIGHT 224
|
||||||
|
|
||||||
static cc_bool launcherMode;
|
static cc_bool launcherMode;
|
||||||
static smpc_peripheral_digital_t state;
|
|
||||||
|
|
||||||
struct _DisplayData DisplayInfo;
|
struct _DisplayData DisplayInfo;
|
||||||
struct _WindowData WindowInfo;
|
struct _WindowData WindowInfo;
|
||||||
@ -109,15 +108,58 @@ static void ProcessButtons(int port, int mods) {
|
|||||||
Gamepad_SetButton(port, CCPAD_DOWN, mods & PERIPHERAL_DIGITAL_DOWN);
|
Gamepad_SetButton(port, CCPAD_DOWN, mods & PERIPHERAL_DIGITAL_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static smpc_peripheral_digital_t dig_state;
|
||||||
|
static smpc_peripheral_analog_t ana_state;
|
||||||
|
|
||||||
void Window_ProcessGamepads(float delta) {
|
void Window_ProcessGamepads(float delta) {
|
||||||
smpc_peripheral_digital_port(1, &state);
|
smpc_peripheral_digital_port(1, &dig_state);
|
||||||
ProcessButtons(0, state.pressed.raw | state.held.raw);
|
ProcessButtons(0, dig_state.pressed.raw | dig_state.held.raw);
|
||||||
|
|
||||||
|
smpc_peripheral_analog_port(1, &ana_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
|
static const vdp2_vram_cycp_t vram_cycp = {
|
||||||
|
.pt[0].t0 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[0].t1 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[0].t2 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[0].t3 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[0].t4 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[0].t5 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[0].t6 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[0].t7 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
|
||||||
|
.pt[1].t0 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[1].t1 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[1].t2 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[1].t3 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[1].t4 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[1].t5 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[1].t6 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[1].t7 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
|
||||||
|
.pt[2].t0 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[2].t1 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[2].t2 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[2].t3 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[2].t4 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[2].t5 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[2].t6 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[2].t7 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
|
||||||
|
.pt[3].t0 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[3].t1 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[3].t2 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[3].t3 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[3].t4 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[3].t5 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[3].t6 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
|
.pt[3].t7 = VDP2_VRAM_CYCP_CHPNDR_NBG0
|
||||||
|
};
|
||||||
|
|
||||||
void Window_Create2D(int width, int height) {
|
void Window_Create2D(int width, int height) {
|
||||||
launcherMode = true;
|
launcherMode = true;
|
||||||
|
|
||||||
@ -132,46 +174,8 @@ void Window_Create2D(int width, int height) {
|
|||||||
vdp2_scrn_bitmap_format_set(&format);
|
vdp2_scrn_bitmap_format_set(&format);
|
||||||
vdp2_scrn_priority_set(VDP2_SCRN_NBG0, 5);
|
vdp2_scrn_priority_set(VDP2_SCRN_NBG0, 5);
|
||||||
vdp2_scrn_display_set(VDP2_SCRN_DISP_NBG0);
|
vdp2_scrn_display_set(VDP2_SCRN_DISP_NBG0);
|
||||||
|
|
||||||
const vdp2_vram_cycp_t vram_cycp = {
|
vdp2_vram_cycp_set(&vram_cycp);
|
||||||
.pt[0].t0 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[0].t1 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[0].t2 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[0].t3 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[0].t4 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[0].t5 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[0].t6 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[0].t7 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
|
|
||||||
.pt[1].t0 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[1].t1 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[1].t2 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[1].t3 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[1].t4 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[1].t5 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[1].t6 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[1].t7 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
|
|
||||||
.pt[2].t0 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[2].t1 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[2].t2 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[2].t3 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[2].t4 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[2].t5 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[2].t6 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[2].t7 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
|
|
||||||
.pt[3].t0 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[3].t1 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[3].t2 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[3].t3 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[3].t4 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[3].t5 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[3].t6 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
|
||||||
.pt[3].t7 = VDP2_VRAM_CYCP_CHPNDR_NBG0
|
|
||||||
};
|
|
||||||
|
|
||||||
vdp2_vram_cycp_set(&vram_cycp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_AllocFramebuffer(struct Bitmap* bmp) {
|
void Window_AllocFramebuffer(struct Bitmap* bmp) {
|
||||||
@ -192,10 +196,10 @@ void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) {
|
|||||||
{
|
{
|
||||||
// TODO optimise
|
// TODO optimise
|
||||||
BitmapCol col = row[x];
|
BitmapCol col = row[x];
|
||||||
cc_uint8 r = BitmapCol_R(col);
|
cc_uint8 R = BitmapCol_R(col);
|
||||||
cc_uint8 g = BitmapCol_G(col);
|
cc_uint8 G = BitmapCol_G(col);
|
||||||
cc_uint8 b = BitmapCol_B(col);
|
cc_uint8 B = BitmapCol_B(col);
|
||||||
vram[x + (y * 512)] = RGB1555(0, r >> 3, g >> 3, b >> 3);
|
vram[x + (y * 512)] = RGB1555(0, R >> 3, G >> 3, B >> 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,12 +247,26 @@ static int MapNativeKey(int k, int l) {
|
|||||||
case DOM_VK_BACK_SLASH: return CCKEY_BACKSLASH;
|
case DOM_VK_BACK_SLASH: return CCKEY_BACKSLASH;
|
||||||
case DOM_VK_CLOSE_BRACKET: return CCKEY_RBRACKET;
|
case DOM_VK_CLOSE_BRACKET: return CCKEY_RBRACKET;
|
||||||
case DOM_VK_QUOTE: return CCKEY_QUOTE;
|
case DOM_VK_QUOTE: return CCKEY_QUOTE;
|
||||||
|
|
||||||
|
case DOM_VK_VOLUME_MUTE: return CCKEY_VOLUME_MUTE;
|
||||||
|
case DOM_VK_VOLUME_DOWN: return CCKEY_VOLUME_DOWN;
|
||||||
|
case DOM_VK_VOLUME_UP: return CCKEY_VOLUME_UP;
|
||||||
|
|
||||||
/* chrome */
|
/* Chrome specific keys */
|
||||||
|
/*case 173: return CCKEY_VOLUME_MUTE; same as DOM_VK_HYPHEN_MINUS */
|
||||||
|
case 174: return CCKEY_VOLUME_DOWN;
|
||||||
|
case 175: return CCKEY_VOLUME_UP;
|
||||||
|
case 176: return CCKEY_MEDIA_NEXT;
|
||||||
|
case 177: return CCKEY_MEDIA_PREV;
|
||||||
|
case 178: return CCKEY_MEDIA_STOP;
|
||||||
|
case 179: return CCKEY_MEDIA_PLAY;
|
||||||
|
|
||||||
case 186: return CCKEY_SEMICOLON;
|
case 186: return CCKEY_SEMICOLON;
|
||||||
case 187: return CCKEY_EQUALS;
|
case 187: return CCKEY_EQUALS;
|
||||||
case 189: return CCKEY_MINUS;
|
case 189: return CCKEY_MINUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Platform_Log1("Unknown key: %i", &k);
|
||||||
return INPUT_NONE;
|
return INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,21 +52,21 @@ static int win_totalWidth, win_totalHeight; /* Size of window including titlebar
|
|||||||
static cc_bool is_ansiWindow, grabCursor;
|
static cc_bool is_ansiWindow, grabCursor;
|
||||||
static int windowX, windowY;
|
static int windowX, windowY;
|
||||||
|
|
||||||
static const cc_uint8 key_map[14 * 16] = {
|
static const cc_uint8 key_map[] = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, CCKEY_BACKSPACE, CCKEY_TAB, 0, 0, CCKEY_F5, CCKEY_ENTER, 0, 0,
|
/* 00 */ 0, 0, 0, 0, 0, 0, 0, 0, CCKEY_BACKSPACE, CCKEY_TAB, 0, 0, CCKEY_F5, CCKEY_ENTER, 0, 0,
|
||||||
0, 0, 0, CCKEY_PAUSE, CCKEY_CAPSLOCK, 0, 0, 0, 0, 0, 0, CCKEY_ESCAPE, 0, 0, 0, 0,
|
/* 10 */ 0, 0, 0, CCKEY_PAUSE, CCKEY_CAPSLOCK, 0, 0, 0, 0, 0, 0, CCKEY_ESCAPE, 0, 0, 0, 0,
|
||||||
CCKEY_SPACE, CCKEY_PAGEUP, CCKEY_PAGEDOWN, CCKEY_END, CCKEY_HOME, CCKEY_LEFT, CCKEY_UP, CCKEY_RIGHT, CCKEY_DOWN, 0, CCKEY_PRINTSCREEN, 0, CCKEY_PRINTSCREEN, CCKEY_INSERT, CCKEY_DELETE, 0,
|
/* 20 */ CCKEY_SPACE, CCKEY_PAGEUP, CCKEY_PAGEDOWN, CCKEY_END, CCKEY_HOME, CCKEY_LEFT, CCKEY_UP, CCKEY_RIGHT, CCKEY_DOWN, 0, CCKEY_PRINTSCREEN, 0, CCKEY_PRINTSCREEN, CCKEY_INSERT, CCKEY_DELETE, 0,
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0, 0, 0,
|
/* 30 */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0, 0, 0,
|
||||||
0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
/* 40 */ 0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', CCKEY_LWIN, CCKEY_RWIN, CCKEY_MENU, 0, 0,
|
/* 50 */ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', CCKEY_LWIN, CCKEY_RWIN, CCKEY_MENU, 0, 0,
|
||||||
CCKEY_KP0, CCKEY_KP1, CCKEY_KP2, CCKEY_KP3, CCKEY_KP4, CCKEY_KP5, CCKEY_KP6, CCKEY_KP7, CCKEY_KP8, CCKEY_KP9, CCKEY_KP_MULTIPLY, CCKEY_KP_PLUS, 0, CCKEY_KP_MINUS, CCKEY_KP_DECIMAL, CCKEY_KP_DIVIDE,
|
/* 60 */ CCKEY_KP0, CCKEY_KP1, CCKEY_KP2, CCKEY_KP3, CCKEY_KP4, CCKEY_KP5, CCKEY_KP6, CCKEY_KP7, CCKEY_KP8, CCKEY_KP9, CCKEY_KP_MULTIPLY, CCKEY_KP_PLUS, 0, CCKEY_KP_MINUS, CCKEY_KP_DECIMAL, CCKEY_KP_DIVIDE,
|
||||||
CCKEY_F1, CCKEY_F2, CCKEY_F3, CCKEY_F4, CCKEY_F5, CCKEY_F6, CCKEY_F7, CCKEY_F8, CCKEY_F9, CCKEY_F10, CCKEY_F11, CCKEY_F12, CCKEY_F13, CCKEY_F14, CCKEY_F15, CCKEY_F16,
|
/* 70 */ CCKEY_F1, CCKEY_F2, CCKEY_F3, CCKEY_F4, CCKEY_F5, CCKEY_F6, CCKEY_F7, CCKEY_F8, CCKEY_F9, CCKEY_F10, CCKEY_F11, CCKEY_F12, CCKEY_F13, CCKEY_F14, CCKEY_F15, CCKEY_F16,
|
||||||
CCKEY_F17, CCKEY_F18, CCKEY_F19, CCKEY_F20, CCKEY_F21, CCKEY_F22, CCKEY_F23, CCKEY_F24, 0, 0, 0, 0, 0, 0, 0, 0,
|
/* 80 */ CCKEY_F17, CCKEY_F18, CCKEY_F19, CCKEY_F20, CCKEY_F21, CCKEY_F22, CCKEY_F23, CCKEY_F24, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
CCKEY_NUMLOCK, CCKEY_SCROLLLOCK, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
/* 90 */ CCKEY_NUMLOCK, CCKEY_SCROLLLOCK, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
CCKEY_LSHIFT, CCKEY_RSHIFT, CCKEY_LCTRL, CCKEY_RCTRL, CCKEY_LALT, CCKEY_RALT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
/* A0 */ CCKEY_LSHIFT, CCKEY_RSHIFT, CCKEY_LCTRL, CCKEY_RCTRL, CCKEY_LALT, CCKEY_RALT, 0, 0, 0, 0, 0, 0, 0, CCKEY_VOLUME_MUTE, CCKEY_VOLUME_DOWN, CCKEY_VOLUME_UP,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CCKEY_SEMICOLON, CCKEY_EQUALS, CCKEY_COMMA, CCKEY_MINUS, CCKEY_PERIOD, CCKEY_SLASH,
|
/* B0 */ CCKEY_MEDIA_NEXT, CCKEY_MEDIA_PREV, CCKEY_MEDIA_STOP, CCKEY_MEDIA_PLAY, 0, 0, 0, 0, 0, 0, CCKEY_SEMICOLON, CCKEY_EQUALS, CCKEY_COMMA, CCKEY_MINUS, CCKEY_PERIOD, CCKEY_SLASH,
|
||||||
CCKEY_TILDE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
/* C0 */ CCKEY_TILDE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CCKEY_LBRACKET, CCKEY_BACKSLASH, CCKEY_RBRACKET, CCKEY_QUOTE, 0,
|
/* D0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CCKEY_LBRACKET, CCKEY_BACKSLASH, CCKEY_RBRACKET, CCKEY_QUOTE, 0,
|
||||||
};
|
};
|
||||||
static int MapNativeKey(WPARAM key, LPARAM meta) {
|
static int MapNativeKey(WPARAM key, LPARAM meta) {
|
||||||
LPARAM ext = meta & (1UL << 24);
|
LPARAM ext = meta & (1UL << 24);
|
||||||
|
@ -474,8 +474,17 @@ static int MapNativeMouse(int button) {
|
|||||||
if (button == 1) return CCMOUSE_L;
|
if (button == 1) return CCMOUSE_L;
|
||||||
if (button == 2) return CCMOUSE_M;
|
if (button == 2) return CCMOUSE_M;
|
||||||
if (button == 3) return CCMOUSE_R;
|
if (button == 3) return CCMOUSE_R;
|
||||||
if (button == 8) return CCMOUSE_X1;
|
|
||||||
if (button == 9) return CCMOUSE_X2;
|
if (button == 8) return CCMOUSE_X1;
|
||||||
|
if (button == 9) return CCMOUSE_X2;
|
||||||
|
if (button == 10) return CCMOUSE_X3;
|
||||||
|
if (button == 11) return CCMOUSE_X4;
|
||||||
|
if (button == 12) return CCMOUSE_X5;
|
||||||
|
if (button == 13) return CCMOUSE_X6;
|
||||||
|
|
||||||
|
/* Mouse horizontal and vertical scroll */
|
||||||
|
if (button >= 4 && button <= 7) return 0;
|
||||||
|
Platform_Log1("Unknown mouse button: %i", &button);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ static int gfx_stride, gfx_format = -1;
|
|||||||
|
|
||||||
static cc_bool gfx_vsync, gfx_fogEnabled;
|
static cc_bool gfx_vsync, gfx_fogEnabled;
|
||||||
static float gfx_minFrameMs;
|
static float gfx_minFrameMs;
|
||||||
|
static cc_bool gfx_rendering2D;
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
@ -284,14 +285,18 @@ void Gfx_Begin2D(int width, int height) {
|
|||||||
|
|
||||||
Gfx_SetDepthTest(false);
|
Gfx_SetDepthTest(false);
|
||||||
Gfx_SetAlphaBlending(true);
|
Gfx_SetAlphaBlending(true);
|
||||||
|
|
||||||
gfx_hadFog = Gfx_GetFog();
|
gfx_hadFog = Gfx_GetFog();
|
||||||
if (gfx_hadFog) Gfx_SetFog(false);
|
if (gfx_hadFog) Gfx_SetFog(false);
|
||||||
|
gfx_rendering2D = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_End2D(void) {
|
void Gfx_End2D(void) {
|
||||||
Gfx_SetDepthTest(true);
|
Gfx_SetDepthTest(true);
|
||||||
Gfx_SetAlphaBlending(false);
|
Gfx_SetAlphaBlending(false);
|
||||||
|
|
||||||
if (gfx_hadFog) Gfx_SetFog(true);
|
if (gfx_hadFog) Gfx_SetFog(true);
|
||||||
|
gfx_rendering2D = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ static const cc_uint8 key_map[8 * 16] = {
|
|||||||
/* 0x30 */ CCKEY_TAB, CCKEY_SPACE, CCKEY_TILDE, CCKEY_BACKSPACE, 0, CCKEY_ESCAPE, 0, 0,
|
/* 0x30 */ CCKEY_TAB, CCKEY_SPACE, CCKEY_TILDE, CCKEY_BACKSPACE, 0, CCKEY_ESCAPE, 0, 0,
|
||||||
/* 0x38 */ 0, CCKEY_CAPSLOCK, 0, 0, 0, 0, 0, 0,
|
/* 0x38 */ 0, CCKEY_CAPSLOCK, 0, 0, 0, 0, 0, 0,
|
||||||
/* 0x40 */ 0, CCKEY_KP_DECIMAL, 0, CCKEY_KP_MULTIPLY, 0, CCKEY_KP_PLUS, 0, CCKEY_NUMLOCK,
|
/* 0x40 */ 0, CCKEY_KP_DECIMAL, 0, CCKEY_KP_MULTIPLY, 0, CCKEY_KP_PLUS, 0, CCKEY_NUMLOCK,
|
||||||
/* 0x48 */ 0, 0, 0, CCKEY_KP_DIVIDE, CCKEY_KP_ENTER, 0, CCKEY_KP_MINUS, 0,
|
/* 0x48 */ CCKEY_VOLUME_UP, CCKEY_VOLUME_DOWN, CCKEY_VOLUME_MUTE, CCKEY_KP_DIVIDE, CCKEY_KP_ENTER, 0, CCKEY_KP_MINUS, 0,
|
||||||
/* 0x50 */ 0, CCKEY_KP_ENTER, CCKEY_KP0, CCKEY_KP1, CCKEY_KP2, CCKEY_KP3, CCKEY_KP4, CCKEY_KP5,
|
/* 0x50 */ 0, CCKEY_KP_ENTER, CCKEY_KP0, CCKEY_KP1, CCKEY_KP2, CCKEY_KP3, CCKEY_KP4, CCKEY_KP5,
|
||||||
/* 0x58 */ CCKEY_KP6, CCKEY_KP7, 0, CCKEY_KP8, CCKEY_KP9, 'N', 'M', CCKEY_PERIOD,
|
/* 0x58 */ CCKEY_KP6, CCKEY_KP7, 0, CCKEY_KP8, CCKEY_KP9, 'N', 'M', CCKEY_PERIOD,
|
||||||
/* 0x60 */ CCKEY_F5, CCKEY_F6, CCKEY_F7, CCKEY_F3, CCKEY_F8, CCKEY_F9, 0, CCKEY_F11,
|
/* 0x60 */ CCKEY_F5, CCKEY_F6, CCKEY_F7, CCKEY_F3, CCKEY_F8, CCKEY_F9, 0, CCKEY_F11,
|
||||||
@ -434,8 +434,15 @@ static int MapNativeMouse(long button) {
|
|||||||
if (button == 0) return CCMOUSE_L;
|
if (button == 0) return CCMOUSE_L;
|
||||||
if (button == 1) return CCMOUSE_R;
|
if (button == 1) return CCMOUSE_R;
|
||||||
if (button == 2) return CCMOUSE_M;
|
if (button == 2) return CCMOUSE_M;
|
||||||
|
|
||||||
if (button == 3) return CCMOUSE_X1;
|
if (button == 3) return CCMOUSE_X1;
|
||||||
if (button == 4) return CCMOUSE_X2;
|
if (button == 4) return CCMOUSE_X2;
|
||||||
|
if (button == 5) return CCMOUSE_X3;
|
||||||
|
if (button == 6) return CCMOUSE_X4;
|
||||||
|
if (button == 7) return CCMOUSE_X5;
|
||||||
|
if (button == 8) return CCMOUSE_X6;
|
||||||
|
|
||||||
|
Platform_Log1("Unknown mouse button: %i", &button);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
third_party/gldc/src/aligned_vector.h
vendored
5
third_party/gldc/src/aligned_vector.h
vendored
@ -83,13 +83,12 @@ AV_FORCE_INLINE void* aligned_vector_at(const AlignedVector* vector, const uint3
|
|||||||
|
|
||||||
AV_FORCE_INLINE void* aligned_vector_reserve(AlignedVector* vector, uint32_t element_count) {
|
AV_FORCE_INLINE void* aligned_vector_reserve(AlignedVector* vector, uint32_t element_count) {
|
||||||
AlignedVectorHeader* hdr = &vector->hdr;
|
AlignedVectorHeader* hdr = &vector->hdr;
|
||||||
|
uint32_t original_byte_size = (hdr->size * AV_ELEMENT_SIZE);
|
||||||
|
|
||||||
if(element_count < hdr->capacity) {
|
if(element_count < hdr->capacity) {
|
||||||
return aligned_vector_at(vector, element_count);
|
return vector->data + original_byte_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t original_byte_size = (hdr->size * AV_ELEMENT_SIZE);
|
|
||||||
|
|
||||||
/* We overallocate so that we don't make small allocations during push backs */
|
/* We overallocate so that we don't make small allocations during push backs */
|
||||||
element_count = ROUND_TO_CHUNK_SIZE(element_count);
|
element_count = ROUND_TO_CHUNK_SIZE(element_count);
|
||||||
|
|
||||||
|
27
third_party/gldc/src/draw.c
vendored
27
third_party/gldc/src/draw.c
vendored
@ -1,28 +1,3 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
extern void apply_poly_header(PolyHeader* header, PolyList* activePolyList);
|
|
||||||
|
|
||||||
GL_FORCE_INLINE Vertex* submitVertices(GLuint vertexCount) {
|
|
||||||
TRACE();
|
|
||||||
PolyList* output = _glActivePolyList();
|
|
||||||
uint32_t header_offset;
|
|
||||||
uint32_t start_offset;
|
|
||||||
|
|
||||||
uint32_t vector_size = aligned_vector_size(&output->vector);
|
|
||||||
GLboolean header_required = (vector_size == 0) || STATE_DIRTY;
|
|
||||||
|
|
||||||
header_offset = vector_size;
|
|
||||||
start_offset = header_offset + (header_required ? 1 : 0);
|
|
||||||
|
|
||||||
/* Make room for the vertices and header */
|
|
||||||
aligned_vector_extend(&output->vector, (header_required) + vertexCount);
|
|
||||||
gl_assert(header_offset < aligned_vector_size(&output->vector));
|
|
||||||
|
|
||||||
if (header_required) {
|
|
||||||
apply_poly_header(aligned_vector_at(&output->vector, header_offset), output);
|
|
||||||
STATE_DIRTY = GL_FALSE;
|
|
||||||
}
|
|
||||||
return aligned_vector_at(&output->vector, start_offset);
|
|
||||||
}
|
|
15
third_party/gldc/src/sh4.c
vendored
15
third_party/gldc/src/sh4.c
vendored
@ -465,7 +465,7 @@ void SceneListSubmit(Vertex* v3, int n) {
|
|||||||
|
|
||||||
for(int i = 0; i < n; ++i, ++v3) {
|
for(int i = 0; i < n; ++i, ++v3) {
|
||||||
PREFETCH(v3 + 1);
|
PREFETCH(v3 + 1);
|
||||||
switch(v3->flags) {
|
switch(v3->flags & 0xFF000000) {
|
||||||
case GPU_CMD_VERTEX_EOL:
|
case GPU_CMD_VERTEX_EOL:
|
||||||
break;
|
break;
|
||||||
case GPU_CMD_VERTEX:
|
case GPU_CMD_VERTEX:
|
||||||
@ -480,12 +480,8 @@ void SceneListSubmit(Vertex* v3, int n) {
|
|||||||
Vertex* const v1 = v3 - 2;
|
Vertex* const v1 = v3 - 2;
|
||||||
Vertex* const v2 = v3 - 1;
|
Vertex* const v2 = v3 - 1;
|
||||||
|
|
||||||
visible_mask = (
|
visible_mask = v3->flags & 0xFF;
|
||||||
(v0->xyz[2] > -v0->w) << 0 |
|
v3->flags &= ~0xFF;
|
||||||
(v1->xyz[2] > -v1->w) << 1 |
|
|
||||||
(v2->xyz[2] > -v2->w) << 2 |
|
|
||||||
(v3->xyz[2] > -v3->w) << 3
|
|
||||||
);
|
|
||||||
|
|
||||||
// Stats gathering found that when testing a 64x64x64 sized world, at most
|
// Stats gathering found that when testing a 64x64x64 sized world, at most
|
||||||
// ~400-500 triangles needed clipping
|
// ~400-500 triangles needed clipping
|
||||||
@ -505,7 +501,7 @@ void SceneListSubmit(Vertex* v3, int n) {
|
|||||||
|
|
||||||
_glPerspectiveDivideVertex(v2);
|
_glPerspectiveDivideVertex(v2);
|
||||||
_glPushHeaderOrVertex(v2);
|
_glPushHeaderOrVertex(v2);
|
||||||
|
|
||||||
_glPerspectiveDivideVertex(v0);
|
_glPerspectiveDivideVertex(v0);
|
||||||
_glPushHeaderOrVertex(v0);
|
_glPushHeaderOrVertex(v0);
|
||||||
|
|
||||||
@ -514,9 +510,6 @@ void SceneListSubmit(Vertex* v3, int n) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0: // No vertices visible
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: // Some vertices visible
|
default: // Some vertices visible
|
||||||
SubmitClipped(v0, v1, v2, v3, visible_mask);
|
SubmitClipped(v0, v1, v2, v3, visible_mask);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user