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)
|
||||||
nop ! align loop
|
ViewportTransformSetup _VP_COL_HWIDTH
|
||||||
|
|
||||||
.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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
bf .TRANSFORM_QUAD ! if T == 0 then goto TRANSFORM_QUAD
|
|
||||||
nop
|
nop
|
||||||
|
|
||||||
rts ! return
|
.NO_POINTS_VISIBLE:
|
||||||
|
bra .LOOP_END ! jump to loop end after executing instruction in delay slot
|
||||||
|
add #-128, r5 ! r5 -= 4 * sizeof(VERTEX), move back to 1 vertex before start of quad
|
||||||
|
|
||||||
|
.SOME_POINTS_VISIBLE:
|
||||||
|
|
||||||
|
.LOOP_END:
|
||||||
|
dt r6 ! r6--; T = r6 == 0
|
||||||
|
bf .TRANSFORM_QUAD ! if !T then goto TRANSFORM_QUAD
|
||||||
nop
|
nop
|
||||||
|
|
||||||
|
add #32, r5 ! r5 += sizeof(VERTEX)
|
||||||
|
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
|
|
||||||
mov r4,r0 ! r0 = src
|
|
||||||
add #-32, r5 ! r5 -= sizeof(VERTEX)
|
add #-32, r5 ! r5 -= sizeof(VERTEX)
|
||||||
|
ViewportTransformSetup _VP_TEX_HWIDTH
|
||||||
|
|
||||||
.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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
bf .TRANSFORM_QUAD ! if T == 0 then goto TRANSFORM_QUAD
|
|
||||||
nop
|
nop
|
||||||
|
|
||||||
rts ! return
|
.NO_POINTS_VISIBLE:
|
||||||
|
bra .LOOP_END ! jump to loop end after executing instruction in delay slot
|
||||||
|
add #-128, r5 ! r5 -= 4 * sizeof(VERTEX), move back to prior quad, so that this invisible quad gets overwritten in next iteration
|
||||||
|
|
||||||
|
.SOME_POINTS_VISIBLE:
|
||||||
|
|
||||||
|
.LOOP_END:
|
||||||
|
dt r6 ! r6--; T = r6 == 0
|
||||||
|
bf .TRANSFORM_QUAD ! if !T then goto TRANSFORM_QUAD
|
||||||
nop
|
nop
|
||||||
|
|
||||||
|
add #32, r5 ! r5 += sizeof(VERTEX)
|
||||||
|
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
|
||||||
|
@ -90,7 +90,7 @@ void Gfx_FreeState(void) {
|
|||||||
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);
|
||||||
@ -99,6 +99,8 @@ void Gfx_Create(void) {
|
|||||||
_primitive_init();
|
_primitive_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Gfx.MinTexWidth = 8;
|
||||||
|
Gfx.MinTexHeight = 8;
|
||||||
Gfx.MaxTexWidth = 128;
|
Gfx.MaxTexWidth = 128;
|
||||||
Gfx.MaxTexHeight = 128;
|
Gfx.MaxTexHeight = 128;
|
||||||
Gfx.Created = true;
|
Gfx.Created = true;
|
||||||
@ -112,8 +114,29 @@ void Gfx_Free(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Textures--------------------------------------------------------*
|
*---------------------------------------------------------Textures--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
|
#define BGRA8_to_SATURN(src) \
|
||||||
|
((src[2] & 0xF8) >> 3) | ((src[1] & 0xF8) << 2) | ((src[0] & 0xF8) << 7) | ((src[3] & 0x80) << 8)
|
||||||
|
|
||||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
return NULL;
|
cc_uint16* tmp = Mem_TryAlloc(bmp->width * bmp->height, 2);
|
||||||
|
if (!tmp) return NULL;
|
||||||
|
|
||||||
|
for (int y = 0; y < bmp->height; y++)
|
||||||
|
{
|
||||||
|
cc_uint32* src = bmp->scan0 + y * rowWidth;
|
||||||
|
cc_uint16* dst = tmp + y * bmp->width;
|
||||||
|
|
||||||
|
for (int x = 0; x < bmp->width; x++)
|
||||||
|
{
|
||||||
|
cc_uint8* color = (cc_uint8*)&src[x];
|
||||||
|
dst[x] = BGRA8_to_SATURN(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scu_dma_transfer(0, _vdp1_vram_partitions.texture_base, tmp, bmp->width * bmp->height * 2);
|
||||||
|
scu_dma_transfer_wait(0);
|
||||||
|
Mem_Free(tmp);
|
||||||
|
return (void*)1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_BindTexture(GfxResourceID texId) {
|
void Gfx_BindTexture(GfxResourceID texId) {
|
||||||
@ -307,14 +330,39 @@ static void Transform(Vec3* result, struct VertexTextured* a, const struct Matri
|
|||||||
float z = a->x * mat->row1.z + a->y * mat->row2.z + a->z * mat->row3.z + mat->row4.z;
|
float z = a->x * mat->row1.z + a->y * mat->row2.z + a->z * mat->row3.z + mat->row4.z;
|
||||||
float w = a->x * mat->row1.w + a->y * mat->row2.w + a->z * mat->row3.w + mat->row4.w;
|
float w = a->x * mat->row1.w + a->y * mat->row2.w + a->z * mat->row3.w + mat->row4.w;
|
||||||
|
|
||||||
result->x = (x/w) * (320/2);
|
result->x = (x/w) * (SCREEN_WIDTH / 2);
|
||||||
result->y = (y/w) * -(224/2);
|
result->y = (y/w) * -(SCREEN_HEIGHT / 2);
|
||||||
result->z = (z/w) * 1024;
|
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
|
#define IsPointCulled(vec) vec.x < -10000 || vec.x > 10000 || vec.y < -10000 || vec.y > 10000 || vec.z < 0 || vec.z > 1024
|
||||||
|
|
||||||
static void DrawTexturedQuads(int verticesCount, int startVertex) {
|
static void DrawTexturedQuads2D(int verticesCount, int startVertex) {
|
||||||
|
for (int i = 0; i < verticesCount; i += 4)
|
||||||
|
{
|
||||||
|
struct VertexTextured* v = (struct VertexTextured*)gfx_vertices + startVertex + i;
|
||||||
|
|
||||||
|
int16_vec2_t points[4];
|
||||||
|
points[0].x = (int)v[0].x - SCREEN_WIDTH / 2; points[0].y = (int)v[0].y - SCREEN_HEIGHT / 2;
|
||||||
|
points[1].x = (int)v[1].x - SCREEN_WIDTH / 2; points[1].y = (int)v[1].y - SCREEN_HEIGHT / 2;
|
||||||
|
points[2].x = (int)v[2].x - SCREEN_WIDTH / 2; points[2].y = (int)v[2].y - SCREEN_HEIGHT / 2;
|
||||||
|
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);
|
||||||
|
int B = PackedCol_B(v->Col);
|
||||||
|
|
||||||
|
vdp1_cmdt_t* cmd;
|
||||||
|
|
||||||
|
cmd = NextPrimitive();
|
||||||
|
vdp1_cmdt_polygon_set(cmd);
|
||||||
|
vdp1_cmdt_color_set(cmd, RGB1555(1, R >> 3, G >> 3, B >> 3));
|
||||||
|
vdp1_cmdt_draw_mode_set(cmd, _primitive_draw_mode);
|
||||||
|
vdp1_cmdt_vtx_set(cmd, points);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DrawTexturedQuads3D(int verticesCount, int startVertex) {
|
||||||
for (int i = 0; i < verticesCount; i += 4)
|
for (int i = 0; i < verticesCount; i += 4)
|
||||||
{
|
{
|
||||||
struct VertexTextured* v = (struct VertexTextured*)gfx_vertices + startVertex + i;
|
struct VertexTextured* v = (struct VertexTextured*)gfx_vertices + startVertex + i;
|
||||||
@ -351,19 +399,23 @@ static void DrawTexturedQuads(int verticesCount, int startVertex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_DrawVb_IndexedTris_Range(int verticesCount, int startVertex) {
|
void Gfx_DrawVb_IndexedTris_Range(int verticesCount, int startVertex) {
|
||||||
if (gfx_format == VERTEX_FORMAT_TEXTURED) {
|
if (gfx_rendering2D && gfx_format == VERTEX_FORMAT_TEXTURED) {
|
||||||
DrawTexturedQuads(verticesCount, startVertex);
|
DrawTexturedQuads2D(verticesCount, startVertex);
|
||||||
|
} else if (gfx_format == VERTEX_FORMAT_TEXTURED) {
|
||||||
|
DrawTexturedQuads3D(verticesCount, startVertex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_DrawVb_IndexedTris(int verticesCount) {
|
void Gfx_DrawVb_IndexedTris(int verticesCount) {
|
||||||
if (gfx_format == VERTEX_FORMAT_TEXTURED) {
|
if (gfx_rendering2D && gfx_format == VERTEX_FORMAT_TEXTURED) {
|
||||||
DrawTexturedQuads(verticesCount, 0);
|
DrawTexturedQuads2D(verticesCount, 0);
|
||||||
|
} else if (gfx_format == VERTEX_FORMAT_TEXTURED) {
|
||||||
|
DrawTexturedQuads3D(verticesCount, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
|
void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
|
||||||
DrawTexturedQuads(verticesCount, startVertex);
|
DrawTexturedQuads3D(verticesCount, startVertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
14
src/Input.c
14
src/Input.c
@ -216,7 +216,12 @@ static const char* const storageNames[INPUT_COUNT] = {
|
|||||||
"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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,8 +42,12 @@ enum InputButtons {
|
|||||||
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,31 +108,21 @@ 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--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void Window_Create2D(int width, int height) {
|
static const vdp2_vram_cycp_t vram_cycp = {
|
||||||
launcherMode = true;
|
|
||||||
|
|
||||||
const vdp2_scrn_bitmap_format_t format = {
|
|
||||||
.scroll_screen = VDP2_SCRN_NBG0,
|
|
||||||
.ccc = VDP2_SCRN_CCC_RGB_32768,
|
|
||||||
.bitmap_size = VDP2_SCRN_BITMAP_SIZE_512X256,
|
|
||||||
.palette_base = 0x00000000,
|
|
||||||
.bitmap_base = VDP2_VRAM_ADDR(0, 0x00000)
|
|
||||||
};
|
|
||||||
|
|
||||||
vdp2_scrn_bitmap_format_set(&format);
|
|
||||||
vdp2_scrn_priority_set(VDP2_SCRN_NBG0, 5);
|
|
||||||
vdp2_scrn_display_set(VDP2_SCRN_DISP_NBG0);
|
|
||||||
|
|
||||||
const vdp2_vram_cycp_t vram_cycp = {
|
|
||||||
.pt[0].t0 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
.pt[0].t0 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
.pt[0].t1 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
.pt[0].t1 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
.pt[0].t2 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
.pt[0].t2 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
@ -169,8 +158,23 @@ void Window_Create2D(int width, int height) {
|
|||||||
.pt[3].t5 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
.pt[3].t5 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
.pt[3].t6 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
.pt[3].t6 = VDP2_VRAM_CYCP_CHPNDR_NBG0,
|
||||||
.pt[3].t7 = VDP2_VRAM_CYCP_CHPNDR_NBG0
|
.pt[3].t7 = VDP2_VRAM_CYCP_CHPNDR_NBG0
|
||||||
|
};
|
||||||
|
|
||||||
|
void Window_Create2D(int width, int height) {
|
||||||
|
launcherMode = true;
|
||||||
|
|
||||||
|
const vdp2_scrn_bitmap_format_t format = {
|
||||||
|
.scroll_screen = VDP2_SCRN_NBG0,
|
||||||
|
.ccc = VDP2_SCRN_CCC_RGB_32768,
|
||||||
|
.bitmap_size = VDP2_SCRN_BITMAP_SIZE_512X256,
|
||||||
|
.palette_base = 0x00000000,
|
||||||
|
.bitmap_base = VDP2_VRAM_ADDR(0, 0x00000)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vdp2_scrn_bitmap_format_set(&format);
|
||||||
|
vdp2_scrn_priority_set(VDP2_SCRN_NBG0, 5);
|
||||||
|
vdp2_scrn_display_set(VDP2_SCRN_DISP_NBG0);
|
||||||
|
|
||||||
vdp2_vram_cycp_set(&vram_cycp);
|
vdp2_vram_cycp_set(&vram_cycp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,11 +248,25 @@ static int MapNativeKey(int k, int l) {
|
|||||||
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;
|
||||||
|
|
||||||
/* chrome */
|
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 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 == 8) return CCMOUSE_X1;
|
||||||
if (button == 9) return CCMOUSE_X2;
|
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);
|
||||||
|
|
||||||
|
25
third_party/gldc/src/draw.c
vendored
25
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);
|
|
||||||
}
|
|
||||||
|
13
third_party/gldc/src/sh4.c
vendored
13
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
|
||||||
@ -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