This commit is contained in:
Zack Buhman 2025-01-20 19:53:23 -06:00
parent 8974ea0654
commit 7c3f1371f1
11 changed files with 473 additions and 156 deletions

29
c/native/sh4intrinsic.c Normal file
View File

@ -0,0 +1,29 @@
#include "sh4intrinsic.h"
void native_jvm_internal_sh4intrinsic_pref1_1(struct vm * vm, uint32_t * args)
{
uint32_t address = (uint32_t)args[0];
// start 32-byte transfer from store queue 0 (SQ0) to QACR0
asm volatile ("pref @%0"
: // output
: "r" (address) // input
: "memory");
}
void native_jvm_internal_sh4intrinsic_pref2_1(struct vm * vm, uint32_t * args)
{
uint32_t address = (uint32_t)args[0];
// start 32-byte transfer from store queue 0 (SQ0) to QACR0
asm volatile ("pref @%0"
: // output
: "r" (address) // input
: "memory");
// start 32-byte transfer from store queue 1 (SQ1) to QACR1
asm volatile ("pref @%0"
: // output
: "r" (address + 32) // input
: "memory");
}

8
c/native/sh4intrinsic.h Normal file
View File

@ -0,0 +1,8 @@
#pragma once
#include <stdint.h>
#include "vm.h"
void native_jvm_internal_sh4intrinsic_pref1_1(struct vm * vm, uint32_t * args);
void native_jvm_internal_sh4intrinsic_pref2_1(struct vm * vm, uint32_t * args);

View File

@ -55,9 +55,6 @@ class JavaCubeDirectoryRecordHandler implements DirectoryRecordHandler {
byte[] buf = dr.array;
int offset = dr.offset + DirectoryRecord.FILE_IDENTIFIER_START;
if (buf[offset] != (byte)'J')
return -1;
for (int i = 0; i < texture_filenames.length; i++) {
byte[] texture_filename = texture_filenames[i].getBytes();
if (bytesEqual(buf, offset, texture_filename, length))

View File

@ -17,8 +17,6 @@ public class Memory {
public static native short getUnalignedU2(int address, boolean bigEndian);
public static native float getUnalignedF4(int address, boolean bigEndian);
public static native void putSQ1(Object object, int address);
public static native boolean isBigEndian();
public static native int allocate(int size);

View File

@ -0,0 +1,6 @@
package jvm.internal;
public class SH4Intrinsic {
public static native void pref1(int address);
public static native void pref2(int address);
}

View File

@ -1,33 +1,47 @@
package sega.dreamcast.holly;
import sega.dreamcast.sh7091.StoreQueueBuffer32;
public class TAVertexParameter {
public static class polygon_type_0 {
public static class polygon_type_0
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
public float z;
public int _res0;
public int _res1;
public int base_color;
public int _res2;
public polygon_type_0(int parameter_control_word,
float x,
float y,
float z,
int base_color
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
this.z = z;
this._res0 = 0;
this._res1 = 0;
this.base_color = base_color;
this._res2 = 0;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putInt(16, 0);
putInt(20, 0);
putInt(24, base_color);
putInt(28, 0);
}
}
public static class polygon_type_1 {
public static class polygon_type_1
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
@ -45,6 +59,7 @@ public class TAVertexParameter {
float base_color_g,
float base_color_b
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
@ -54,33 +69,54 @@ public class TAVertexParameter {
this.base_color_g = base_color_g;
this.base_color_b = base_color_b;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putFloat(16, base_color_alpha);
putFloat(20, base_color_r);
putFloat(24, base_color_g);
putFloat(28, base_color_b);
}
public static class polygon_type_2 {
}
public static class polygon_type_2
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
public float z;
public int _res0;
public int _res1;
public float base_intensity;
public int _res2;
public polygon_type_2(int parameter_control_word,
float x,
float y,
float z,
float base_intensity
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
this.z = z;
this._res0 = 0;
this._res1 = 0;
this.base_intensity = base_intensity;
this._res2 = 0;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putInt(16, 0);
putInt(20, 0);
putFloat(24, base_intensity);
putInt(28, 0);
}
}
public static class polygon_type_3 {
public static class polygon_type_3
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
@ -98,6 +134,7 @@ public class TAVertexParameter {
int base_color,
int offset_color
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
@ -107,14 +144,26 @@ public class TAVertexParameter {
this.base_color = base_color;
this.offset_color = offset_color;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putFloat(16, u);
putFloat(20, v);
putInt(24, base_color);
putInt(28, offset_color);
}
public static class polygon_type_4 {
}
public static class polygon_type_4
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
public float z;
public int u_v;
public int _res0;
public int base_color;
public int offset_color;
public polygon_type_4(int parameter_control_word,
@ -125,25 +174,36 @@ public class TAVertexParameter {
int base_color,
int offset_color
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
this.z = z;
this.u_v = u_v;
this._res0 = 0;
this.base_color = base_color;
this.offset_color = offset_color;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putInt(16, u_v);
putInt(20, 0);
putInt(24, base_color);
putInt(28, offset_color);
}
public static class polygon_type_5 {
}
public static class polygon_type_5
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
public float z;
public float u;
public float v;
public int _res0;
public int _res1;
public float base_color_alpha;
public float base_color_r;
public float base_color_g;
@ -167,14 +227,13 @@ public class TAVertexParameter {
float offset_color_g,
float offset_color_b
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
this.z = z;
this.u = u;
this.v = v;
this._res0 = 0;
this._res1 = 0;
this.base_color_alpha = base_color_alpha;
this.base_color_r = base_color_r;
this.base_color_g = base_color_g;
@ -184,16 +243,34 @@ public class TAVertexParameter {
this.offset_color_g = offset_color_g;
this.offset_color_b = offset_color_b;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putFloat(16, u);
putFloat(20, v);
putInt(24, 0);
putInt(28, 0);
putFloat(32, base_color_alpha);
putFloat(36, base_color_r);
putFloat(40, base_color_g);
putFloat(44, base_color_b);
putFloat(48, offset_color_alpha);
putFloat(52, offset_color_r);
putFloat(56, offset_color_g);
putFloat(60, offset_color_b);
}
public static class polygon_type_6 {
}
public static class polygon_type_6
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
public float z;
public int u_v;
public int _res0;
public int _res1;
public int _res2;
public float base_color_alpha;
public float base_color_r;
public float base_color_g;
@ -216,14 +293,12 @@ public class TAVertexParameter {
float offset_color_g,
float offset_color_b
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
this.z = z;
this.u_v = u_v;
this._res0 = 0;
this._res1 = 0;
this._res2 = 0;
this.base_color_alpha = base_color_alpha;
this.base_color_r = base_color_r;
this.base_color_g = base_color_g;
@ -233,8 +308,29 @@ public class TAVertexParameter {
this.offset_color_g = offset_color_g;
this.offset_color_b = offset_color_b;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putInt(16, u_v);
putInt(20, 0);
putInt(24, 0);
putInt(28, 0);
putFloat(32, base_color_alpha);
putFloat(36, base_color_r);
putFloat(40, base_color_g);
putFloat(44, base_color_b);
putFloat(48, offset_color_alpha);
putFloat(52, offset_color_r);
putFloat(56, offset_color_g);
putFloat(60, offset_color_b);
}
public static class polygon_type_7 {
}
public static class polygon_type_7
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
@ -252,6 +348,7 @@ public class TAVertexParameter {
float base_intensity,
float offset_intensity
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
@ -261,14 +358,26 @@ public class TAVertexParameter {
this.base_intensity = base_intensity;
this.offset_intensity = offset_intensity;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putFloat(16, u);
putFloat(20, v);
putFloat(24, base_intensity);
putFloat(28, offset_intensity);
}
public static class polygon_type_8 {
}
public static class polygon_type_8
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
public float z;
public int u_v;
public int _res0;
public float base_intensity;
public float offset_intensity;
public polygon_type_8(int parameter_control_word,
@ -279,25 +388,36 @@ public class TAVertexParameter {
float base_intensity,
float offset_intensity
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
this.z = z;
this.u_v = u_v;
this._res0 = 0;
this.base_intensity = base_intensity;
this.offset_intensity = offset_intensity;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putInt(16, u_v);
putInt(20, 0);
putFloat(24, base_intensity);
putFloat(28, offset_intensity);
}
public static class polygon_type_9 {
}
public static class polygon_type_9
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
public float z;
public int base_color_0;
public int base_color_1;
public int _res0;
public int _res1;
public polygon_type_9(int parameter_control_word,
float x,
float y,
@ -305,25 +425,35 @@ public class TAVertexParameter {
int base_color_0,
int base_color_1
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
this.z = z;
this.base_color_0 = base_color_0;
this.base_color_1 = base_color_1;
this._res0 = 0;
this._res1 = 0;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putInt(16, base_color_0);
putInt(20, base_color_1);
putInt(24, 0);
putInt(28, 0);
}
}
public static class polygon_type_10 {
public static class polygon_type_10
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
public float z;
public int base_intensity_0;
public int base_intensity_1;
public int _res0;
public int _res1;
public polygon_type_10(int parameter_control_word,
float x,
float y,
@ -331,17 +461,29 @@ public class TAVertexParameter {
int base_intensity_0,
int base_intensity_1
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
this.z = z;
this.base_intensity_0 = base_intensity_0;
this.base_intensity_1 = base_intensity_1;
this._res0 = 0;
this._res1 = 0;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putInt(16, base_intensity_0);
putInt(20, base_intensity_1);
putInt(24, 0);
putInt(28, 0);
}
}
public static class polygon_type_11 {
public static class polygon_type_11
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
@ -354,10 +496,6 @@ public class TAVertexParameter {
public float v_1;
public int base_color_1;
public int offset_color_1;
public int _res0;
public int _res1;
public int _res2;
public int _res3;
public polygon_type_11(int parameter_control_word,
float x,
float y,
@ -371,6 +509,7 @@ public class TAVertexParameter {
int base_color_1,
int offset_color_1
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
@ -383,29 +522,40 @@ public class TAVertexParameter {
this.v_1 = v_1;
this.base_color_1 = base_color_1;
this.offset_color_1 = offset_color_1;
this._res0 = 0;
this._res1 = 0;
this._res2 = 0;
this._res3 = 0;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putFloat(16, u_0);
putFloat(20, v_0);
putInt(24, base_color_0);
putInt(28, offset_color_0);
putFloat(32, u_1);
putFloat(36, v_1);
putInt(40, base_color_1);
putInt(44, offset_color_1);
putInt(48, 0);
putInt(52, 0);
putInt(56, 0);
putInt(60, 0);
}
}
public static class polygon_type_12 {
public static class polygon_type_12
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
public float z;
public int u_v_0;
public int _res0;
public int base_color_0;
public int offset_color_0;
public int u_v_1;
public int _res1;
public int base_color_1;
public int offset_color_1;
public int _res2;
public int _res3;
public int _res4;
public int _res5;
public polygon_type_12(int parameter_control_word,
float x,
float y,
@ -417,25 +567,41 @@ public class TAVertexParameter {
int base_color_1,
int offset_color_1
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
this.z = z;
this.u_v_0 = u_v_0;
this._res0 = 0;
this.base_color_0 = base_color_0;
this.offset_color_0 = offset_color_0;
this.u_v_1 = u_v_1;
this._res1 = 0;
this.base_color_1 = base_color_1;
this.offset_color_1 = offset_color_1;
this._res2 = 0;
this._res3 = 0;
this._res4 = 0;
this._res5 = 0;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putInt(16, u_v_0);
putInt(20, 0);
putInt(24, base_color_0);
putInt(28, offset_color_0);
putInt(32, u_v_1);
putInt(36, 0);
putInt(40, base_color_1);
putInt(44, offset_color_1);
putInt(48, 0);
putInt(52, 0);
putInt(56, 0);
putInt(60, 0);
}
}
public static class polygon_type_13 {
public static class polygon_type_13
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
@ -448,10 +614,6 @@ public class TAVertexParameter {
public float v_1;
public int base_intensity_1;
public float offset_intensity_1;
public int _res0;
public int _res1;
public int _res2;
public int _res3;
public polygon_type_13(int parameter_control_word,
float x,
float y,
@ -465,6 +627,7 @@ public class TAVertexParameter {
int base_intensity_1,
float offset_intensity_1
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
@ -477,29 +640,40 @@ public class TAVertexParameter {
this.v_1 = v_1;
this.base_intensity_1 = base_intensity_1;
this.offset_intensity_1 = offset_intensity_1;
this._res0 = 0;
this._res1 = 0;
this._res2 = 0;
this._res3 = 0;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putFloat(16, u_0);
putFloat(20, v_0);
putInt(24, base_intensity_0);
putFloat(28, offset_intensity_0);
putFloat(32, u_1);
putFloat(36, v_1);
putInt(40, base_intensity_1);
putFloat(44, offset_intensity_1);
putInt(48, 0);
putInt(52, 0);
putInt(56, 0);
putInt(60, 0);
}
}
public static class polygon_type_14 {
public static class polygon_type_14
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float x;
public float y;
public float z;
public int u_v_0;
public int _res0;
public int base_intensity_0;
public float offset_intensity_0;
public int u_v_1;
public int _res1;
public int base_intensity_1;
public float offset_intensity_1;
public int _res2;
public int _res3;
public int _res4;
public int _res5;
public polygon_type_14(int parameter_control_word,
float x,
float y,
@ -511,25 +685,41 @@ public class TAVertexParameter {
int base_intensity_1,
float offset_intensity_1
) {
super();
this.parameter_control_word = parameter_control_word;
this.x = x;
this.y = y;
this.z = z;
this.u_v_0 = u_v_0;
this._res0 = 0;
this.base_intensity_0 = base_intensity_0;
this.offset_intensity_0 = offset_intensity_0;
this.u_v_1 = u_v_1;
this._res1 = 0;
this.base_intensity_1 = base_intensity_1;
this.offset_intensity_1 = offset_intensity_1;
this._res2 = 0;
this._res3 = 0;
this._res4 = 0;
this._res5 = 0;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, x);
putFloat(8, y);
putFloat(12, z);
putInt(16, u_v_0);
putInt(20, 0);
putInt(24, base_intensity_0);
putFloat(28, offset_intensity_0);
putInt(32, u_v_1);
putInt(36, 0);
putInt(40, base_intensity_1);
putFloat(44, offset_intensity_1);
putInt(48, 0);
putInt(52, 0);
putInt(56, 0);
putInt(60, 0);
}
}
public static class sprite_type_0 {
public static class sprite_type_0
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float a_x;
public float a_y;
@ -542,10 +732,6 @@ public class TAVertexParameter {
public float c_z;
public float d_x;
public float d_y;
public int _res0;
public int _res1;
public int _res2;
public int _res3;
public sprite_type_0(int parameter_control_word,
float a_x,
float a_y,
@ -559,6 +745,7 @@ public class TAVertexParameter {
float d_x,
float d_y
) {
super();
this.parameter_control_word = parameter_control_word;
this.a_x = a_x;
this.a_y = a_y;
@ -571,13 +758,30 @@ public class TAVertexParameter {
this.c_z = c_z;
this.d_x = d_x;
this.d_y = d_y;
this._res0 = 0;
this._res1 = 0;
this._res2 = 0;
this._res3 = 0;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, a_x);
putFloat(8, a_y);
putFloat(12, a_z);
putFloat(16, b_x);
putFloat(20, b_y);
putFloat(24, b_z);
putFloat(28, c_x);
putFloat(32, c_y);
putFloat(36, c_z);
putFloat(40, d_x);
putFloat(44, d_y);
putInt(48, 0);
putInt(52, 0);
putInt(56, 0);
putInt(60, 0);
}
}
public static class sprite_type_1 {
public static class sprite_type_1
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float a_x;
public float a_y;
@ -590,7 +794,6 @@ public class TAVertexParameter {
public float c_z;
public float d_x;
public float d_y;
public int _res0;
public int a_u_a_v;
public int b_u_b_v;
public int c_u_c_v;
@ -610,6 +813,7 @@ public class TAVertexParameter {
int b_u_b_v,
int c_u_c_v
) {
super();
this.parameter_control_word = parameter_control_word;
this.a_x = a_x;
this.a_y = a_y;
@ -622,13 +826,33 @@ public class TAVertexParameter {
this.c_z = c_z;
this.d_x = d_x;
this.d_y = d_y;
this._res0 = 0;
this.a_u_a_v = a_u_a_v;
this.b_u_b_v = b_u_b_v;
this.c_u_c_v = c_u_c_v;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, a_x);
putFloat(8, a_y);
putFloat(12, a_z);
putFloat(16, b_x);
putFloat(20, b_y);
putFloat(24, b_z);
putFloat(28, c_x);
putFloat(32, c_y);
putFloat(36, c_z);
putFloat(40, d_x);
putFloat(44, d_y);
putInt(48, 0);
putInt(52, a_u_a_v);
putInt(56, b_u_b_v);
putInt(60, c_u_c_v);
}
public static class modifier_volume {
}
public static class modifier_volume
extends StoreQueueBuffer
implements GdromCommandPacketInterface {
public int parameter_control_word;
public float a_x;
public float a_y;
@ -639,12 +863,6 @@ public class TAVertexParameter {
public float c_x;
public float c_y;
public float c_z;
public int _res0;
public int _res1;
public int _res2;
public int _res3;
public int _res4;
public int _res5;
public modifier_volume(int parameter_control_word,
float a_x,
float a_y,
@ -656,6 +874,7 @@ public class TAVertexParameter {
float c_y,
float c_z
) {
super();
this.parameter_control_word = parameter_control_word;
this.a_x = a_x;
this.a_y = a_y;
@ -666,12 +885,24 @@ public class TAVertexParameter {
this.c_x = c_x;
this.c_y = c_y;
this.c_z = c_z;
this._res0 = 0;
this._res1 = 0;
this._res2 = 0;
this._res3 = 0;
this._res4 = 0;
this._res5 = 0;
}
public void submit() {
putInt(0, parameter_control_word);
putFloat(4, a_x);
putFloat(8, a_y);
putFloat(12, a_z);
putFloat(16, b_x);
putFloat(20, b_y);
putFloat(24, b_z);
putFloat(28, c_x);
putFloat(32, c_y);
putFloat(36, c_z);
putInt(40, 0);
putInt(44, 0);
putInt(48, 0);
putInt(52, 0);
putInt(56, 0);
putInt(60, 0);
}
}
}

View File

@ -0,0 +1,13 @@
package sega.dreamcast.sh7091;
import java.nio.ByteBuffer;
import sega.dreamcast.MemoryMap;
public abstract class StoreQueueBuffer extends ByteBuffer {
public StoreQueueBuffer() {
super(MemoryMap.store_queue, 0, 64, 64, true);
}
public abstract void submit();
}

View File

@ -1,29 +1,32 @@
python gen_decoder.py > c/decode.inc.c
CLASS_DIRECTORY=./classes
LIB=./dreamcast
python gen_decoder.py > "${CLASS_DIRECTORY}"/c/decode.inc.c
# [block name] [package name] [class_name] [base_address]
python regs/register_gen.py ../dreamcast/regs/holly.csv holly holly Holly 0xa05f8000 > sega/dreamcast/holly/Holly.java
python regs/register_gen.py ../dreamcast/regs/systembus.csv systembus systembus Systembus 0xa05f6800 > sega/dreamcast/systembus/Systembus.java
python regs/register_gen.py ../dreamcast/regs/systembus.csv maple_if maple MapleIF 0xa05f6c00 > sega/dreamcast/maple/MapleIF.java
python regs/register_gen.py ../dreamcast/regs/gdrom.csv gdrom gdrom Gdrom 0xa05f7000 > sega/dreamcast/gdrom/Gdrom.java
python regs/register_gen.py ../dreamcast/regs/systembus.csv g1_if gdrom G1IF 0xa05f7400 > sega/dreamcast/gdrom/G1IF.java
python regs/register_gen.py ../dreamcast/regs/systembus.csv g2_if g2_if G2IF 0xa05f7800 > sega/dreamcast/g2_if/G2IF.java
python regs/register_gen.py ../dreamcast/regs/systembus.csv pvr_if pvr_if PVRIF 0xa05f7c00 > sega/dreamcast/pvr_if/PVRIF.java
python regs/register_gen.py "${LIB}"/regs/holly.csv holly holly Holly 0xa05f8000 > "${CLASS_DIRECTORY}"/sega/dreamcast/holly/Holly.java
python regs/register_gen.py "${LIB}"/regs/systembus.csv systembus systembus Systembus 0xa05f6800 > "${CLASS_DIRECTORY}"/sega/dreamcast/systembus/Systembus.java
python regs/register_gen.py "${LIB}"/regs/systembus.csv maple_if maple MapleIF 0xa05f6c00 > "${CLASS_DIRECTORY}"/sega/dreamcast/maple/MapleIF.java
python regs/register_gen.py "${LIB}"/regs/gdrom.csv gdrom gdrom Gdrom 0xa05f7000 > "${CLASS_DIRECTORY}"/sega/dreamcast/gdrom/Gdrom.java
python regs/register_gen.py "${LIB}"/regs/systembus.csv g1_if gdrom G1IF 0xa05f7400 > "${CLASS_DIRECTORY}"/sega/dreamcast/gdrom/G1IF.java
python regs/register_gen.py "${LIB}"/regs/systembus.csv g2_if g2_if G2IF 0xa05f7800 > "${CLASS_DIRECTORY}"/sega/dreamcast/g2_if/G2IF.java
python regs/register_gen.py "${LIB}"/regs/systembus.csv pvr_if pvr_if PVRIF 0xa05f7c00 > "${CLASS_DIRECTORY}"/sega/dreamcast/pvr_if/PVRIF.java
python regs/bits_gen.py ../dreamcast/regs/core_bits.csv holly CoreBits > sega/dreamcast/holly/CoreBits.java
python regs/bits_gen.py ../dreamcast/regs/ta_bits.csv holly TABits > sega/dreamcast/holly/TABits.java
python regs/bits_gen.py ../dreamcast/regs/isp_tsp.csv holly ISPTSP > sega/dreamcast/holly/ISPTSP.java
python regs/bits_gen.py ../dreamcast/regs/ta_parameter.csv holly TAParameter > sega/dreamcast/holly/TAParameter.java
python regs/bits_gen.py ../dreamcast/regs/gdrom_bits.csv gdrom GdromBits > sega/dreamcast/gdrom/GdromBits.java
python regs/bits_gen.py "${LIB}"/regs/core_bits.csv holly CoreBits > "${CLASS_DIRECTORY}"/sega/dreamcast/holly/CoreBits.java
python regs/bits_gen.py "${LIB}"/regs/ta_bits.csv holly TABits > "${CLASS_DIRECTORY}"/sega/dreamcast/holly/TABits.java
python regs/bits_gen.py "${LIB}"/regs/isp_tsp.csv holly ISPTSP > "${CLASS_DIRECTORY}"/sega/dreamcast/holly/ISPTSP.java
python regs/bits_gen.py "${LIB}"/regs/ta_parameter.csv holly TAParameter > "${CLASS_DIRECTORY}"/sega/dreamcast/holly/TAParameter.java
python regs/bits_gen.py "${LIB}"/regs/gdrom_bits.csv gdrom GdromBits > "${CLASS_DIRECTORY}"/sega/dreamcast/gdrom/GdromBits.java
python regs/bits_gen.py ../dreamcast/regs/systembus_bits.csv systembus SystembusBits > sega/dreamcast/systembus/SystembusBits.java
python regs/bits_gen.py "${LIB}"/regs/systembus_bits.csv systembus SystembusBits > "${CLASS_DIRECTORY}"/sega/dreamcast/systembus/SystembusBits.java
python regs/ta_parameters.py ../dreamcast/regs/vertex_parameter_format.csv holly TAVertexParameter > sega/dreamcast/holly/TAVertexParameter.java
python regs/ta_parameters.py ../dreamcast/regs/global_parameter_format.csv holly TAGlobalParameter > sega/dreamcast/holly/TAGlobalParameter.java
python regs/ta_parameters.py "${LIB}"/regs/vertex_parameter_format.csv holly TAVertexParameter > "${CLASS_DIRECTORY}"/sega/dreamcast/holly/TAVertexParameter.java
python regs/ta_parameters.py "${LIB}"/regs/global_parameter_format.csv holly TAGlobalParameter > "${CLASS_DIRECTORY}"/sega/dreamcast/holly/TAGlobalParameter.java
PYTHONPATH=./regs/ python ../model_generator/generate_java.py cube.obj CubeModel > ./model/CubeModel.java
PYTHONPATH=./regs/ python ../model_generator/generate_java.py cube.obj CubeModel > "${CLASS_DIRECTORY}"/./model/CubeModel.java
python images/color_convert.py images/java_cup.png argb4444 images/java_cup.data
python images/color_convert.py images/java_text.png argb4444 images/java_text.data
python images/color_convert.py images/java_powered.png argb4444 images/java_powered.data
python regs/gdrom_command_packet_format.py ../dreamcast/regs/gdrom_command_packet_format.csv gdrom GdromCommandPacketFormat > sega/dreamcast/gdrom/GdromCommandPacketFormat.java
python regs/gdrom_command_packet_format.py "${LIB}"/regs/gdrom_command_packet_format.csv gdrom GdromCommandPacketFormat > "${CLASS_DIRECTORY}"/sega/dreamcast/gdrom/GdromCommandPacketFormat.java

View File

@ -1,4 +0,0 @@
class Holly {
public static final int
}

View File

@ -1,6 +1,6 @@
def render_fields(get_type, fields, want_get_byte):
def render_fields(get_type, fields):
for field in fields:
if want_get_byte and field.name.startswith("_res"):
if field.name.startswith("_res"):
continue
field_type = get_type(field.name)
@ -10,7 +10,7 @@ def render_fields(get_type, fields, want_get_byte):
for i in range(field.array_length):
yield f"public {field_type} {field.name}{i};"
def render_constructor(get_type, declaration, want_get_byte):
def render_constructor(get_type, declaration, store_queue_buffer):
initializer = f"public {declaration.name}("
padding = " " * len(initializer)
def start(i):
@ -34,8 +34,10 @@ def render_constructor(get_type, declaration, want_get_byte):
else:
yield initializer + ') {'
yield "super();"
for i, field in enumerate(declaration.fields):
if want_get_byte and field.name.startswith("_res"):
if field.name.startswith("_res"):
continue
value = field.name if not field.name.startswith('_res') else '0'
@ -60,8 +62,8 @@ def render_get_byte(fields):
yield "switch (ix) {"
for field in fields:
if "_res" in field.name:
pass
elif field.array_length == 1:
continue
if field.array_length == 1:
yield f"case {ix}: return {field.name};"
else:
for i in range(field.array_length):
@ -71,18 +73,50 @@ def render_get_byte(fields):
yield "}"
yield "}"
def render_declaration(get_type, declaration, want_get_byte):
yield f"public static class {declaration.name} implements GdromCommandPacketInterface {{"
yield from render_fields(get_type, declaration.fields, want_get_byte)
yield from render_constructor(get_type, declaration, want_get_byte)
if want_get_byte:
yield from render_get_byte(declaration.fields)
def render_submit(get_type, fields):
yield "public void submit() {"
for i, field in enumerate(fields):
index = i * 4
value = "0" if "_res" in field.name else field.name
field_type = get_type(field.name)
if field_type == "int":
yield f"putInt({index}, {value});"
elif field_type == "float":
yield f"putFloat({index}, {value});"
else:
assert False, field_type
yield "Memory.putU4(0xff000038, MemoryMap.ta_fifo_polygon_converter); // QACR0";
if len(fields) == 16:
yield "Memory.putU4(0xff00003c, MemoryMap.ta_fifo_polygon_converter); // QACR1";
if len(fields) == 8:
yield "SH4Intrinsic.pref1(MemoryMap.store_queue);"
else:
yield "SH4Intrinsic.pref2(MemoryMap.store_queue);"
yield "}"
def render_declarations(get_type, package_name, class_name, declarations, want_get_byte=False):
def render_declaration(get_type, declaration, store_queue_buffer, get_byte):
yield f"public static class {declaration.name}"
if store_queue_buffer:
assert len(declaration.fields) in {8, 16}, len(declaration.fields)
yield " extends StoreQueueBuffer"
yield " implements GdromCommandPacketInterface {"
yield ""
yield from render_fields(get_type, declaration.fields)
yield from render_constructor(get_type, declaration, store_queue_buffer)
if get_byte:
yield from render_get_byte(declaration.fields)
if store_queue_buffer:
yield from render_submit(get_type, declaration.fields)
yield "}"
def render_declarations(get_type, package_name, class_name, declarations, *, store_queue_buffer, get_byte):
yield f"package sega.dreamcast.{package_name};"
yield ""
if store_queue_buffer:
yield "import sega.dreamcast.sh7091.StoreQueueBuffer32;"
yield ""
yield f"public class {class_name} {{"
for declaration in declarations:
yield from render_declaration(get_type, declaration, want_get_byte)
yield from render_declaration(get_type, declaration, store_queue_buffer, get_byte)
yield "}"

View File

@ -65,5 +65,7 @@ if __name__ == "__main__":
expected_offset=4,
expected_sizes={32, 64})
render, out = renderer(indent_length=4)
render(render_declarations(get_type, package_name, class_name, declarations))
render(render_declarations(get_type, package_name, class_name, declarations,
store_queue_buffer=True,
get_byte=False))
sys.stdout.write(out.getvalue())