load texture data from gdrom
This commit is contained in:
parent
55cc54eda3
commit
3e35137e07
@ -1,7 +1,7 @@
|
|||||||
import example.DreamcastVideo2;
|
import example.JavaCube;
|
||||||
|
|
||||||
class Main {
|
class Main {
|
||||||
public static void main() {
|
public static void main() {
|
||||||
DreamcastVideo2.main();
|
JavaCube.main();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,8 @@ jvm.iso: boot.bin main.bin zero.bin
|
|||||||
sega/dreamcast/gdrom/GdromCommandPacketInterface.class \
|
sega/dreamcast/gdrom/GdromCommandPacketInterface.class \
|
||||||
sega/dreamcast/gdrom/GdromProtocol.class \
|
sega/dreamcast/gdrom/GdromProtocol.class \
|
||||||
Main.class \
|
Main.class \
|
||||||
example/DreamcastVideo2.class \
|
example/JavaCube.class \
|
||||||
|
example/JavaCubeDirectoryRecordHandler.class \
|
||||||
model/FacePTN.class \
|
model/FacePTN.class \
|
||||||
model/ModelObject.class \
|
model/ModelObject.class \
|
||||||
model/UntitledModel.class \
|
model/UntitledModel.class \
|
||||||
@ -130,7 +131,9 @@ jvm.iso: boot.bin main.bin zero.bin
|
|||||||
sega/dreamcast/holly/TAVertexParameter_polygon_type_3.class \
|
sega/dreamcast/holly/TAVertexParameter_polygon_type_3.class \
|
||||||
sega/dreamcast/holly/TextureMemoryAllocation.class \
|
sega/dreamcast/holly/TextureMemoryAllocation.class \
|
||||||
java/lang/Math.class \
|
java/lang/Math.class \
|
||||||
java/misc/Resource.class
|
java/misc/Resource.class \
|
||||||
|
images/java_text.data \
|
||||||
|
images/java_cup.data
|
||||||
|
|
||||||
main.elf: LDSCRIPT = $(LIB)/main.lds
|
main.elf: LDSCRIPT = $(LIB)/main.lds
|
||||||
main.elf: $(START_OBJ) $(OBJ) $(MAIN_OBJ) $(MAIN_DREAMCAST_OBJ) $(LIBGCC_OBJ) $(CLASS_PATH)
|
main.elf: $(START_OBJ) $(OBJ) $(MAIN_OBJ) $(MAIN_DREAMCAST_OBJ) $(LIBGCC_OBJ) $(CLASS_PATH)
|
||||||
|
17
c/execute.c
17
c/execute.c
@ -1541,11 +1541,18 @@ void op_ldc2_w(struct vm * vm, uint32_t index)
|
|||||||
void op_ldc_w(struct vm * vm, uint32_t index)
|
void op_ldc_w(struct vm * vm, uint32_t index)
|
||||||
{
|
{
|
||||||
struct constant * constant = &vm->current_frame->class_entry->class_file->constant_pool[index - 1];
|
struct constant * constant = &vm->current_frame->class_entry->class_file->constant_pool[index - 1];
|
||||||
#ifdef DEBUG
|
if (constant->tag == CONSTANT_Integer || constant->tag == CONSTANT_Float) {
|
||||||
assert(constant->tag == CONSTANT_Integer || constant->tag == CONSTANT_Float);
|
int32_t value = constant->integer.bytes;
|
||||||
#endif
|
operand_stack_push_u32(vm->current_frame, value);
|
||||||
int32_t value = constant->integer.bytes;
|
} else if (constant->tag == CONSTANT_String) {
|
||||||
operand_stack_push_u32(vm->current_frame, value);
|
int32_t * objectref = class_resolver_lookup_string(vm->class_hash_table.length,
|
||||||
|
vm->class_hash_table.entry,
|
||||||
|
vm->current_frame->class_entry,
|
||||||
|
constant->string.string_index);
|
||||||
|
operand_stack_push_u32(vm->current_frame, (uint32_t)objectref);
|
||||||
|
} else {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void op_ldiv(struct vm * vm)
|
void op_ldiv(struct vm * vm)
|
||||||
|
@ -37,8 +37,6 @@ class GdromDirectoryRecordHandler implements DirectoryRecordHandler {
|
|||||||
|
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
for (int i = length - 5; i < length; i++) {
|
for (int i = length - 5; i < length; i++) {
|
||||||
System.out.print(ix);
|
|
||||||
System.out.print(" ");
|
|
||||||
if (buf[offset + i] != class_ext[ix]) {
|
if (buf[offset + i] != class_ext[ix]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,68 @@ import model.FacePTN;
|
|||||||
import model.ModelObject;
|
import model.ModelObject;
|
||||||
import java.misc.Memory;
|
import java.misc.Memory;
|
||||||
import java.misc.Resource;
|
import java.misc.Resource;
|
||||||
|
import filesystem.iso9660.VolumeParser;
|
||||||
|
import filesystem.iso9660.DirectoryRecordHandler;
|
||||||
|
import filesystem.iso9660.DirectoryRecord;
|
||||||
|
import sega.dreamcast.gdrom.GdromExtentReader;
|
||||||
|
import sega.dreamcast.gdrom.GdromProtocol;
|
||||||
|
import sega.dreamcast.gdrom.GdromIF;
|
||||||
|
import sega.dreamcast.gdrom.G1IF;
|
||||||
|
import sega.dreamcast.gdrom.Gdrom;
|
||||||
|
import java.misc.Memory;
|
||||||
|
|
||||||
public class DreamcastVideo2 {
|
class JavaCubeDirectoryRecordHandler implements DirectoryRecordHandler {
|
||||||
|
int[] texture_extents;
|
||||||
|
String[] texture_filenames;
|
||||||
|
|
||||||
|
JavaCubeDirectoryRecordHandler(int[] texture_extents, String[] texture_filenames) {
|
||||||
|
this.texture_extents = texture_extents;
|
||||||
|
this.texture_filenames = texture_filenames;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean bytesEqual(byte[] a, int a_offset, byte[] b, int length) {
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
if (a[a_offset + i] != b[i])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int isTexture(DirectoryRecord dr) {
|
||||||
|
int length = dr.lengthOfFileIdentifier();
|
||||||
|
if (length != 14)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
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))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handle(DirectoryRecord dr) {
|
||||||
|
int texture_index = isTexture(dr);
|
||||||
|
if (texture_index >= 0) {
|
||||||
|
int extent = dr.locationOfExtent(); // sector number
|
||||||
|
/*
|
||||||
|
System.out.print("texture extent: ");
|
||||||
|
System.out.print(texture_index);
|
||||||
|
System.out.print(": ");
|
||||||
|
System.out.println(extent);
|
||||||
|
*/
|
||||||
|
texture_extents[texture_index] = extent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JavaCube {
|
||||||
static final int framebuffer_width = 640;
|
static final int framebuffer_width = 640;
|
||||||
static final int framebuffer_height = 480;
|
static final int framebuffer_height = 480;
|
||||||
|
|
||||||
@ -43,7 +103,19 @@ public class DreamcastVideo2 {
|
|||||||
11479204, 4042586, 16676239
|
11479204, 4042586, 16676239
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static int[] texture_extents;
|
||||||
|
|
||||||
|
static String[] texture_filenames = {
|
||||||
|
"JAVA_CUP.DAT;1",
|
||||||
|
"JAVA_TEX.DAT;1",
|
||||||
|
};
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
texture_extents = new int[texture_filenames.length];
|
||||||
|
for (int i = 0; i < texture_filenames.length; i++) {
|
||||||
|
texture_extents[i] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
int parameter_control_word = TAParameter.para_control__para_type__polygon_or_modifier_volume
|
int parameter_control_word = TAParameter.para_control__para_type__polygon_or_modifier_volume
|
||||||
| TAParameter.para_control__list_type__translucent
|
| TAParameter.para_control__list_type__translucent
|
||||||
| TAParameter.obj_control__col_type__packed_color
|
| TAParameter.obj_control__col_type__packed_color
|
||||||
@ -237,29 +309,33 @@ public class DreamcastVideo2 {
|
|||||||
public static void transfer_textures() {
|
public static void transfer_textures() {
|
||||||
int texture = TextureMemoryAllocation.texture_regions[1][0] + 512;
|
int texture = TextureMemoryAllocation.texture_regions[1][0] + 512;
|
||||||
|
|
||||||
/*
|
int data_track_fad = GdromProtocol.tocGetDataTrackFad();
|
||||||
// java_cup
|
|
||||||
int[] java_cup = Resource.getResource("images/java_cup");
|
|
||||||
int java_cup_length = (java_cup == null) ? 0 : java_cup.length;
|
|
||||||
//System.out.print("images/java_cup length: ");
|
|
||||||
//System.out.println(java_cup_length);
|
|
||||||
|
|
||||||
for (int i = 0; i < java_cup_length; i++) {
|
JavaCubeDirectoryRecordHandler handler
|
||||||
Memory.putU4(MemoryMap.texture_memory64 + texture, java_cup[i]);
|
= new JavaCubeDirectoryRecordHandler(texture_extents, texture_filenames);
|
||||||
texture += 4;
|
GdromExtentReader reader = new GdromExtentReader();
|
||||||
|
VolumeParser parser = new VolumeParser(data_track_fad - 150, reader, handler);
|
||||||
|
parser.parse();
|
||||||
|
|
||||||
|
for (int i = 0; i < texture_extents.length; i++) {
|
||||||
|
int length = 512 * 512 * 2;
|
||||||
|
int sectors = length >> 11; // division by 2048
|
||||||
|
|
||||||
|
System.out.println(texture);
|
||||||
|
if (texture_extents[i] >= 0) {
|
||||||
|
int extent = texture_extents[i];
|
||||||
|
Memory.putU4(G1IF.GDEN, 0);
|
||||||
|
GdromProtocol.cdReadDMA(extent + 150, sectors);
|
||||||
|
GdromIF.startG1DMA(MemoryMap.texture_memory64 + texture, length);
|
||||||
|
while ((Memory.getU4(G1IF.GDST) & 1) != 0);
|
||||||
|
System.out.println("transfer complete");
|
||||||
|
int status = Memory.getU1(Gdrom.status);
|
||||||
|
System.out.print("status: ");
|
||||||
|
System.out.println(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
texture += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// java_text
|
|
||||||
int[] java_text = Resource.getResource("images/java_text");
|
|
||||||
int java_text_length = (java_text == null) ? 0 : java_text.length;
|
|
||||||
//System.out.print("images/java_text length: ");
|
|
||||||
//System.out.println(java_text_length);
|
|
||||||
|
|
||||||
for (int i = 0; i < java_text_length; i++) {
|
|
||||||
Memory.putU4(MemoryMap.texture_memory64 + texture, java_text[i]);
|
|
||||||
texture += 4;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void transfer_java_powered() {
|
public static void transfer_java_powered() {
|
||||||
@ -340,7 +416,9 @@ public class DreamcastVideo2 {
|
|||||||
|
|
||||||
Core.init();
|
Core.init();
|
||||||
|
|
||||||
boot_splash(ta_alloc, opb_size_total);
|
for (int i = 0; i < 2; i++) {
|
||||||
|
boot_splash(ta_alloc, opb_size_total);
|
||||||
|
}
|
||||||
|
|
||||||
transfer_textures();
|
transfer_textures();
|
||||||
|
|
||||||
@ -348,6 +426,8 @@ public class DreamcastVideo2 {
|
|||||||
Background.background(TextureMemoryAllocation.background_start[1],
|
Background.background(TextureMemoryAllocation.background_start[1],
|
||||||
background_color);
|
background_color);
|
||||||
|
|
||||||
|
Memory.putU4(Holly.VO_BORDER_COL, background_color);
|
||||||
|
|
||||||
RegionArray.region_array(framebuffer_width / 32,
|
RegionArray.region_array(framebuffer_width / 32,
|
||||||
framebuffer_height / 32,
|
framebuffer_height / 32,
|
||||||
opb_size,
|
opb_size,
|
@ -46,7 +46,7 @@ class color_format:
|
|||||||
|
|
||||||
def convert_colors(f, convert, colors):
|
def convert_colors(f, convert, colors):
|
||||||
assert len(colors) % 2 == 0, len(colors)
|
assert len(colors) % 2 == 0, len(colors)
|
||||||
f.write(struct.pack("<I", (len(colors) * 2) // 4))
|
#f.write(struct.pack("<I", (len(colors) * 2) // 4))
|
||||||
for color in colors:
|
for color in colors:
|
||||||
value = convert(*color)
|
value = convert(*color)
|
||||||
f.write(struct.pack("<H", value))
|
f.write(struct.pack("<H", value))
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 512 KiB After Width: | Height: | Size: 512 KiB |
@ -3,7 +3,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern C {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern uint32_t _binary_images_java_cup_data_start __asm("_binary_images_java_cup_data_start");
|
extern uint32_t _binary_images_java_cup_data_start __asm("_binary_images_java_cup_data_start");
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 512 KiB After Width: | Height: | Size: 512 KiB |
@ -3,7 +3,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern C {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern uint32_t _binary_images_java_text_data_start __asm("_binary_images_java_text_data_start");
|
extern uint32_t _binary_images_java_text_data_start __asm("_binary_images_java_text_data_start");
|
||||||
|
@ -8,7 +8,7 @@ public class GdromIF {
|
|||||||
public static void startG1DMA(int start_address, int transfer_length) {
|
public static void startG1DMA(int start_address, int transfer_length) {
|
||||||
int gdstar = start_address & ~(0b111 << 29);
|
int gdstar = start_address & ~(0b111 << 29);
|
||||||
|
|
||||||
Memory.putU4(G1IF.GDAPRO, 0x8843407F);
|
Memory.putU4(G1IF.GDAPRO, 0x8843007F);
|
||||||
Memory.putU4(G1IF.G1GDRC, 0x00001001);
|
Memory.putU4(G1IF.G1GDRC, 0x00001001);
|
||||||
Memory.putU4(G1IF.GDSTAR, gdstar);
|
Memory.putU4(G1IF.GDSTAR, gdstar);
|
||||||
Memory.putU4(G1IF.GDLEN, transfer_length);
|
Memory.putU4(G1IF.GDLEN, transfer_length);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user