(re)add GdromCommandPacketFormat
This commit is contained in:
parent
fef6715d17
commit
a8f3b5e921
@ -1,5 +1,7 @@
|
||||
#include "example/DreamcastVideo2.class.h"
|
||||
#include "example/DreamcastVideo.class.h"
|
||||
#include "example/GdromTest.class.h"
|
||||
#include "example/Vec2.class.h"
|
||||
#include "java/io/PrintStream.class.h"
|
||||
#include "java/lang/Boolean.class.h"
|
||||
#include "java/lang/Byte.class.h"
|
||||
@ -26,6 +28,23 @@
|
||||
#include "model/Vec3.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromBits.class.h"
|
||||
#include "sega/dreamcast/gdrom/Gdrom.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_open.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_play.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_read2.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_read.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_scan.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_scd.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_seek.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_get_toc.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_req_error.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_req_mode.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_req_ses.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_req_stat.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_set_mode.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketFormat_test_unit.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromCommandPacketInterface.class.h"
|
||||
#include "sega/dreamcast/gdrom/GdromProtocol.class.h"
|
||||
#include "sega/dreamcast/holly/Background.class.h"
|
||||
#include "sega/dreamcast/holly/CoreBits.class.h"
|
||||
#include "sega/dreamcast/holly/Core.class.h"
|
||||
|
@ -1,5 +1,7 @@
|
||||
(const uint8_t *)&_binary_example_DreamcastVideo2_class_start,
|
||||
(const uint8_t *)&_binary_example_DreamcastVideo_class_start,
|
||||
(const uint8_t *)&_binary_example_GdromTest_class_start,
|
||||
(const uint8_t *)&_binary_example_Vec2_class_start,
|
||||
(const uint8_t *)&_binary_java_io_PrintStream_class_start,
|
||||
(const uint8_t *)&_binary_java_lang_Boolean_class_start,
|
||||
(const uint8_t *)&_binary_java_lang_Byte_class_start,
|
||||
@ -26,6 +28,23 @@
|
||||
(const uint8_t *)&_binary_model_Vec3_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromBits_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_Gdrom_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_open_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_play_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read2_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scan_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scd_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_seek_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_get_toc_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_error_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_mode_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_ses_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_stat_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_set_mode_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_test_unit_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromCommandPacketInterface_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_gdrom_GdromProtocol_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_holly_Background_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_holly_CoreBits_class_start,
|
||||
(const uint8_t *)&_binary_sega_dreamcast_holly_Core_class_start,
|
||||
|
@ -18,9 +18,14 @@ void main()
|
||||
};
|
||||
int class_file_buffers_length = (sizeof (class_file_buffers)) / (sizeof (class_file_buffers[0]));
|
||||
|
||||
const uint8_t * main_class = (const uint8_t *)"example/DreamcastVideo2";
|
||||
//const uint8_t * main_class = (const uint8_t *)"example/DreamcastVideo2";
|
||||
const uint8_t * main_class = (const uint8_t *)"example/GdromTest";
|
||||
int main_class_length = string_length((const char *)main_class);
|
||||
|
||||
for (int i = 0; i < main_class_length; i++)
|
||||
scif_character(main_class[i]);
|
||||
scif_character('\n');
|
||||
|
||||
int class_hash_table_length;
|
||||
struct hash_table_entry * class_hash_table = class_resolver_load_from_buffers(class_file_buffers,
|
||||
class_file_buffers_length,
|
||||
|
19
classpath.mk
19
classpath.mk
@ -1,6 +1,8 @@
|
||||
CLASS_PATH = \
|
||||
example/DreamcastVideo2.class.o \
|
||||
example/DreamcastVideo.class.o \
|
||||
example/GdromTest.class.o \
|
||||
example/Vec2.class.o \
|
||||
java/io/PrintStream.class.o \
|
||||
java/lang/Boolean.class.o \
|
||||
java/lang/Byte.class.o \
|
||||
@ -27,6 +29,23 @@ CLASS_PATH = \
|
||||
model/Vec3.class.o \
|
||||
sega/dreamcast/gdrom/GdromBits.class.o \
|
||||
sega/dreamcast/gdrom/Gdrom.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_open.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_play.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_read2.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_read.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_scan.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_scd.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_seek.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_get_toc.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_req_error.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_req_mode.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_req_ses.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_req_stat.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_set_mode.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketFormat_test_unit.class.o \
|
||||
sega/dreamcast/gdrom/GdromCommandPacketInterface.class.o \
|
||||
sega/dreamcast/gdrom/GdromProtocol.class.o \
|
||||
sega/dreamcast/holly/Background.class.o \
|
||||
sega/dreamcast/holly/CoreBits.class.o \
|
||||
sega/dreamcast/holly/Core.class.o \
|
||||
|
15
example/GdromTest.class.h
Normal file
15
example/GdromTest.class.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_example_GdromTest_class_start __asm("_binary_example_GdromTest_class_start");
|
||||
extern uint32_t _binary_example_GdromTest_class_end __asm("_binary_example_GdromTest_class_end");
|
||||
extern uint32_t _binary_example_GdromTest_class_size __asm("_binary_example_GdromTest_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
9
example/GdromTest.java
Normal file
9
example/GdromTest.java
Normal file
@ -0,0 +1,9 @@
|
||||
package example;
|
||||
|
||||
import sega.dreamcast.gdrom.GdromProtocol;
|
||||
|
||||
class GdromTest {
|
||||
public static void main() {
|
||||
GdromProtocol.tocGetDataTrackFad();
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ from sparse_struct import parse
|
||||
from sparse_struct_java import render_declarations
|
||||
|
||||
def get_type(field_name: str):
|
||||
return "byte"
|
||||
return "int"
|
||||
|
||||
if __name__ == "__main__":
|
||||
rows = read_input_headerless(sys.argv[1])
|
||||
|
@ -1,5 +1,8 @@
|
||||
def render_fields(get_type, fields):
|
||||
def render_fields(get_type, fields, want_get_byte):
|
||||
for field in fields:
|
||||
if want_get_byte and field.name.startswith("_res"):
|
||||
continue
|
||||
|
||||
field_type = get_type(field.name)
|
||||
if field.array_length == 1:
|
||||
yield f"public {field_type} {field.name};"
|
||||
@ -7,7 +10,7 @@ def render_fields(get_type, fields):
|
||||
for i in range(field.array_length):
|
||||
yield f"public {field_type} {field.name}{i};"
|
||||
|
||||
def render_constructor(get_type, declaration):
|
||||
def render_constructor(get_type, declaration, want_get_byte):
|
||||
initializer = f"public {declaration.name}("
|
||||
padding = " " * len(initializer)
|
||||
def start(i):
|
||||
@ -32,6 +35,9 @@ def render_constructor(get_type, declaration):
|
||||
yield initializer + ') {'
|
||||
|
||||
for i, field in enumerate(declaration.fields):
|
||||
if want_get_byte and field.name.startswith("_res"):
|
||||
continue
|
||||
|
||||
value = field.name if not field.name.startswith('_res') else '0'
|
||||
value = hex(field.default) if field.default is not None else value
|
||||
s = ':' if i == 0 else ','
|
||||
@ -41,7 +47,7 @@ def render_constructor(get_type, declaration):
|
||||
max_shift = 8 * (field.array_length - 1)
|
||||
for i in range(field.array_length):
|
||||
shift = max_shift - (i * 8)
|
||||
yield f"this.{field.name}{i} = (byte)(({field.name} >> {shift}) & 0xff);"
|
||||
yield f"this.{field.name}{i} = ({field.name} >> {shift}) & 0xff;"
|
||||
|
||||
yield "}"
|
||||
|
||||
@ -50,7 +56,7 @@ def render_constructor(get_type, declaration):
|
||||
|
||||
def render_get_byte(fields):
|
||||
ix = 0
|
||||
yield "public int get_byte(int ix) {"
|
||||
yield "public int getByte(int ix) {"
|
||||
yield "switch (ix) {"
|
||||
for field in fields:
|
||||
if "_res" in field.name:
|
||||
@ -66,9 +72,9 @@ def render_get_byte(fields):
|
||||
yield "}"
|
||||
|
||||
def render_declaration(get_type, declaration, want_get_byte):
|
||||
yield f"public static class {declaration.name} {{"
|
||||
yield from render_fields(get_type, declaration.fields)
|
||||
yield from render_constructor(get_type, declaration)
|
||||
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)
|
||||
yield "}"
|
||||
|
15
sega/dreamcast/gdrom/GdromCommandPacketFormat.class.h
Normal file
15
sega/dreamcast/gdrom/GdromCommandPacketFormat.class.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
336
sega/dreamcast/gdrom/GdromCommandPacketFormat.java
Normal file
336
sega/dreamcast/gdrom/GdromCommandPacketFormat.java
Normal file
@ -0,0 +1,336 @@
|
||||
package sega.dreamcast.gdrom;
|
||||
|
||||
|
||||
public class GdromCommandPacketFormat {
|
||||
public static class test_unit implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public test_unit() {
|
||||
this.command_code = 0x0;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class req_stat implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public int starting_address;
|
||||
public int allocation_length;
|
||||
public req_stat(int starting_address,
|
||||
int allocation_length
|
||||
) {
|
||||
this.command_code = 0x10;
|
||||
this.starting_address = starting_address;
|
||||
this.allocation_length = allocation_length;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
case 2: return starting_address;
|
||||
case 4: return allocation_length;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class req_mode implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public int starting_address;
|
||||
public int allocation_length;
|
||||
public req_mode(int starting_address,
|
||||
int allocation_length
|
||||
) {
|
||||
this.command_code = 0x11;
|
||||
this.starting_address = starting_address;
|
||||
this.allocation_length = allocation_length;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
case 2: return starting_address;
|
||||
case 4: return allocation_length;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class set_mode implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public int starting_address;
|
||||
public int allocation_length;
|
||||
public set_mode(int starting_address,
|
||||
int allocation_length
|
||||
) {
|
||||
this.command_code = 0x12;
|
||||
this.starting_address = starting_address;
|
||||
this.allocation_length = allocation_length;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
case 2: return starting_address;
|
||||
case 4: return allocation_length;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class req_error implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public int allocation_length;
|
||||
public req_error(int allocation_length
|
||||
) {
|
||||
this.command_code = 0x13;
|
||||
this.allocation_length = allocation_length;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
case 4: return allocation_length;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class get_toc implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public int select;
|
||||
public int allocation_length0;
|
||||
public int allocation_length1;
|
||||
public get_toc(int select,
|
||||
int allocation_length
|
||||
) {
|
||||
this.command_code = 0x14;
|
||||
this.select = select;
|
||||
this.allocation_length0 = (allocation_length >> 8) & 0xff;
|
||||
this.allocation_length1 = (allocation_length >> 0) & 0xff;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
case 1: return select;
|
||||
case 3: return allocation_length0;
|
||||
case 4: return allocation_length1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class req_ses implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public int session_number;
|
||||
public int allocation_length;
|
||||
public req_ses(int session_number,
|
||||
int allocation_length
|
||||
) {
|
||||
this.command_code = 0x15;
|
||||
this.session_number = session_number;
|
||||
this.allocation_length = allocation_length;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
case 2: return session_number;
|
||||
case 4: return allocation_length;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class cd_open implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public cd_open() {
|
||||
this.command_code = 0x16;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class cd_play implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public int parameter_type;
|
||||
public int starting_point0;
|
||||
public int starting_point1;
|
||||
public int starting_point2;
|
||||
public int repeat_times;
|
||||
public int end_point0;
|
||||
public int end_point1;
|
||||
public int end_point2;
|
||||
public cd_play(int parameter_type,
|
||||
int starting_point,
|
||||
int repeat_times,
|
||||
int end_point
|
||||
) {
|
||||
this.command_code = 0x20;
|
||||
this.parameter_type = parameter_type;
|
||||
this.starting_point0 = (starting_point >> 16) & 0xff;
|
||||
this.starting_point1 = (starting_point >> 8) & 0xff;
|
||||
this.starting_point2 = (starting_point >> 0) & 0xff;
|
||||
this.repeat_times = repeat_times;
|
||||
this.end_point0 = (end_point >> 16) & 0xff;
|
||||
this.end_point1 = (end_point >> 8) & 0xff;
|
||||
this.end_point2 = (end_point >> 0) & 0xff;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
case 1: return parameter_type;
|
||||
case 2: return starting_point0;
|
||||
case 3: return starting_point1;
|
||||
case 4: return starting_point2;
|
||||
case 6: return repeat_times;
|
||||
case 8: return end_point0;
|
||||
case 9: return end_point1;
|
||||
case 10: return end_point2;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class cd_seek implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public int parameter_type;
|
||||
public int seek_point0;
|
||||
public int seek_point1;
|
||||
public int seek_point2;
|
||||
public cd_seek(int parameter_type,
|
||||
int seek_point
|
||||
) {
|
||||
this.command_code = 0x21;
|
||||
this.parameter_type = parameter_type;
|
||||
this.seek_point0 = (seek_point >> 16) & 0xff;
|
||||
this.seek_point1 = (seek_point >> 8) & 0xff;
|
||||
this.seek_point2 = (seek_point >> 0) & 0xff;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
case 1: return parameter_type;
|
||||
case 2: return seek_point0;
|
||||
case 3: return seek_point1;
|
||||
case 4: return seek_point2;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class cd_scan implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public int direction;
|
||||
public int speed;
|
||||
public cd_scan(int direction,
|
||||
int speed
|
||||
) {
|
||||
this.command_code = 0x22;
|
||||
this.direction = direction;
|
||||
this.speed = speed;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
case 2: return direction;
|
||||
case 3: return speed;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class cd_read implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public int data;
|
||||
public int starting_address0;
|
||||
public int starting_address1;
|
||||
public int starting_address2;
|
||||
public int transfer_length0;
|
||||
public int transfer_length1;
|
||||
public int transfer_length2;
|
||||
public cd_read(int data,
|
||||
int starting_address,
|
||||
int transfer_length
|
||||
) {
|
||||
this.command_code = 0x30;
|
||||
this.data = data;
|
||||
this.starting_address0 = (starting_address >> 16) & 0xff;
|
||||
this.starting_address1 = (starting_address >> 8) & 0xff;
|
||||
this.starting_address2 = (starting_address >> 0) & 0xff;
|
||||
this.transfer_length0 = (transfer_length >> 16) & 0xff;
|
||||
this.transfer_length1 = (transfer_length >> 8) & 0xff;
|
||||
this.transfer_length2 = (transfer_length >> 0) & 0xff;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
case 1: return data;
|
||||
case 2: return starting_address0;
|
||||
case 3: return starting_address1;
|
||||
case 4: return starting_address2;
|
||||
case 8: return transfer_length0;
|
||||
case 9: return transfer_length1;
|
||||
case 10: return transfer_length2;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class cd_read2 implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public int data;
|
||||
public int starting_address0;
|
||||
public int starting_address1;
|
||||
public int starting_address2;
|
||||
public int transfer_length0;
|
||||
public int transfer_length1;
|
||||
public int next_address0;
|
||||
public int next_address1;
|
||||
public int next_address2;
|
||||
public cd_read2(int data,
|
||||
int starting_address,
|
||||
int transfer_length,
|
||||
int next_address
|
||||
) {
|
||||
this.command_code = 0x31;
|
||||
this.data = data;
|
||||
this.starting_address0 = (starting_address >> 16) & 0xff;
|
||||
this.starting_address1 = (starting_address >> 8) & 0xff;
|
||||
this.starting_address2 = (starting_address >> 0) & 0xff;
|
||||
this.transfer_length0 = (transfer_length >> 8) & 0xff;
|
||||
this.transfer_length1 = (transfer_length >> 0) & 0xff;
|
||||
this.next_address0 = (next_address >> 16) & 0xff;
|
||||
this.next_address1 = (next_address >> 8) & 0xff;
|
||||
this.next_address2 = (next_address >> 0) & 0xff;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
case 1: return data;
|
||||
case 2: return starting_address0;
|
||||
case 3: return starting_address1;
|
||||
case 4: return starting_address2;
|
||||
case 6: return transfer_length0;
|
||||
case 7: return transfer_length1;
|
||||
case 8: return next_address0;
|
||||
case 9: return next_address1;
|
||||
case 10: return next_address2;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class cd_scd implements GdromCommandPacketInterface {
|
||||
public int command_code;
|
||||
public int data_format;
|
||||
public int allocation_length0;
|
||||
public int allocation_length1;
|
||||
public cd_scd(int data_format,
|
||||
int allocation_length
|
||||
) {
|
||||
this.command_code = 0x40;
|
||||
this.data_format = data_format;
|
||||
this.allocation_length0 = (allocation_length >> 8) & 0xff;
|
||||
this.allocation_length1 = (allocation_length >> 0) & 0xff;
|
||||
}
|
||||
public int getByte(int ix) {
|
||||
switch (ix) {
|
||||
case 0: return command_code;
|
||||
case 1: return data_format;
|
||||
case 3: return allocation_length0;
|
||||
case 4: return allocation_length1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_open_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_open_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_open_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_open_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_open_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_open_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_play_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_play_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_play_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_play_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_play_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_play_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read2_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read2_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read2_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read2_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read2_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_read2_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scan_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scan_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scan_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scan_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scan_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scan_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
15
sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_scd.class.h
Normal file
15
sega/dreamcast/gdrom/GdromCommandPacketFormat_cd_scd.class.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scd_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scd_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scd_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scd_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scd_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_scd_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_seek_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_seek_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_seek_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_seek_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_seek_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_cd_seek_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_get_toc_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_get_toc_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_get_toc_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_get_toc_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_get_toc_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_get_toc_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_error_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_error_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_error_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_error_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_error_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_error_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_mode_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_mode_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_mode_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_mode_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_mode_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_mode_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_ses_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_ses_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_ses_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_ses_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_ses_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_ses_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_stat_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_stat_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_stat_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_stat_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_stat_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_req_stat_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_set_mode_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_set_mode_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_set_mode_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_set_mode_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_set_mode_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_set_mode_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_test_unit_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_test_unit_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_test_unit_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_test_unit_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_test_unit_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketFormat_test_unit_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
15
sega/dreamcast/gdrom/GdromCommandPacketInterface.class.h
Normal file
15
sega/dreamcast/gdrom/GdromCommandPacketInterface.class.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketInterface_class_start __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketInterface_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketInterface_class_end __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketInterface_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromCommandPacketInterface_class_size __asm("_binary_sega_dreamcast_gdrom_GdromCommandPacketInterface_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
5
sega/dreamcast/gdrom/GdromCommandPacketInterface.java
Normal file
5
sega/dreamcast/gdrom/GdromCommandPacketInterface.java
Normal file
@ -0,0 +1,5 @@
|
||||
package sega.dreamcast.gdrom;
|
||||
|
||||
public interface GdromCommandPacketInterface {
|
||||
public int getByte(int ix);
|
||||
}
|
15
sega/dreamcast/gdrom/GdromProtocol.class.h
Normal file
15
sega/dreamcast/gdrom/GdromProtocol.class.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern C {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromProtocol_class_start __asm("_binary_sega_dreamcast_gdrom_GdromProtocol_class_start");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromProtocol_class_end __asm("_binary_sega_dreamcast_gdrom_GdromProtocol_class_end");
|
||||
extern uint32_t _binary_sega_dreamcast_gdrom_GdromProtocol_class_size __asm("_binary_sega_dreamcast_gdrom_GdromProtocol_class_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
98
sega/dreamcast/gdrom/GdromProtocol.java
Normal file
98
sega/dreamcast/gdrom/GdromProtocol.java
Normal file
@ -0,0 +1,98 @@
|
||||
package sega.dreamcast.gdrom;
|
||||
|
||||
import java.misc.Memory;
|
||||
import sega.dreamcast.gdrom.GdromCommandPacketFormat;
|
||||
|
||||
public class GdromProtocol {
|
||||
static GdromCommandPacketFormat.get_toc get_toc_command;
|
||||
static short[] toc_buf;
|
||||
|
||||
static {
|
||||
int single_density_area = 0;
|
||||
int maximum_toc_length = 0x0198;
|
||||
get_toc_command = new GdromCommandPacketFormat.get_toc(single_density_area,
|
||||
maximum_toc_length);
|
||||
|
||||
toc_buf = new short[maximum_toc_length >> 1];
|
||||
}
|
||||
|
||||
public static void packetCommand(GdromCommandPacketInterface command, boolean enable_dma) {
|
||||
while (true) {
|
||||
int status = Memory.getU1(Gdrom.status);
|
||||
if ((GdromBits.status__bsy(status) | GdromBits.status__drq(status)) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
int features = enable_dma ? GdromBits.features__dma__enable : GdromBits.features__dma__disable;
|
||||
Memory.putU1(Gdrom.features, features);
|
||||
|
||||
int drive_select = GdromBits.drive_select__drive_select
|
||||
| GdromBits.drive_select__lun(0);
|
||||
Memory.putU1(Gdrom.drive_select, drive_select);
|
||||
|
||||
Memory.putU1(Gdrom.command, GdromBits.command__code__packet_command);
|
||||
|
||||
System.out.println("words:");
|
||||
for (int i = 0; i < 6; i++) {
|
||||
int i0 = command.getByte(i * 2);
|
||||
int i1 = command.getByte(i * 2 + 1);
|
||||
// little endian
|
||||
int word = ((i1 & 0xff) << 8) | (i0 & 0xff);
|
||||
System.out.println(word);
|
||||
Memory.putU2(Gdrom.data, word);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
int status = Memory.getU1(Gdrom.status);
|
||||
if (GdromBits.status__bsy(status) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void readData(short[] buf, int length) {
|
||||
for (int i = 0; i < (length >> 1); i++) {
|
||||
buf[i] = (short)Memory.getU2(Gdrom.data);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getFad(short[] buf, int i) {
|
||||
int low = toc_buf[i * 2] & 0xffff;
|
||||
int high = toc_buf[i * 2 + 1] & 0xffff;
|
||||
int i0 = (high >> 8) & 0xff;
|
||||
int i1 = high & 0xff;
|
||||
int i2 = (low >> 8) & 0xff;
|
||||
//int i3 = low & 0xff;
|
||||
|
||||
return (i2 << 16) | (i1 << 8) | i0;
|
||||
}
|
||||
|
||||
public static int tocGetDataTrackFad() {
|
||||
System.out.println("PacketCommand:");
|
||||
packetCommand(get_toc_command, false); // PIO mode
|
||||
|
||||
int low = Memory.getU1(Gdrom.byte_count_low);
|
||||
int high = Memory.getU1(Gdrom.byte_count_high);
|
||||
int byte_count = ((high & 0xff) << 8) | (low & 0xff);
|
||||
System.out.print("byte count:");
|
||||
System.out.println(byte_count);
|
||||
|
||||
System.out.println("tracks:");
|
||||
readData(toc_buf, byte_count);
|
||||
for (int i = 0; i < 99; i++) {
|
||||
int fad = getFad(toc_buf, i);
|
||||
if (fad == 0xffffff)
|
||||
break;
|
||||
System.out.print("[");
|
||||
System.out.print(i);
|
||||
System.out.print("] ");
|
||||
System.out.println(fad);
|
||||
}
|
||||
|
||||
int status = Memory.getU1(Gdrom.status);
|
||||
System.out.print("status: ");
|
||||
System.out.println(status);
|
||||
|
||||
// assume track 1 is the correct track
|
||||
return getFad(toc_buf, 1);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user