Skip to content

Commit 91beafe

Browse files
overdrivenpotatosajattack
authored andcommitted
Flatten imports in gu.rs
Fix style errors
1 parent 6936bc2 commit 91beafe

File tree

17 files changed

+477
-383
lines changed

17 files changed

+477
-383
lines changed

src/psp/audio.rs

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,67 @@ pub enum AudioInputFrequency {
4646
Khz11_025 = 11025,
4747
}
4848

49-
extern {
50-
pub fn sceAudioChReserve(channel: i32, sample_count: i32, format: AudioFormat) -> i32;
49+
extern "C" {
50+
pub fn sceAudioChReserve(
51+
channel: i32,
52+
sample_count: i32,
53+
format: AudioFormat,
54+
) -> i32;
5155
pub fn sceAudioChRelease(channel: i32) -> i32;
5256
pub fn sceAudioOutput(channel: i32, vol: i32, buf: *mut c_void) -> i32;
53-
pub fn sceAudioOutputBlocking(channel: i32, vol: i32, buf: *mut c_void) -> i32;
54-
pub fn sceAudioOutputPanned(channel: i32, left_vol: i32, right_vol: i32, buf: *mut c_void) -> i32;
55-
pub fn sceAudioOutputPannedBlocking(channel: i32, left_vol: i32, right_vol: i32, buf: *mut c_void) -> i32;
57+
pub fn sceAudioOutputBlocking(
58+
channel: i32,
59+
vol: i32,
60+
buf: *mut c_void,
61+
) -> i32;
62+
pub fn sceAudioOutputPanned(
63+
channel: i32,
64+
left_vol: i32,
65+
right_vol: i32,
66+
buf: *mut c_void,
67+
) -> i32;
68+
pub fn sceAudioOutputPannedBlocking(
69+
channel: i32,
70+
left_vol: i32,
71+
right_vol: i32,
72+
buf: *mut c_void,
73+
) -> i32;
5674
pub fn sceAudioGetChannelRestLen(channel: i32) -> i32;
5775
pub fn sceAudioGetChannelRestLength(channel: i32) -> i32;
5876
pub fn sceAudioSetChannelDataLen(channel: i32, sample_count: i32) -> i32;
59-
pub fn sceAudioChangeChannelConfig(channel: i32, format: AudioFormat) -> i32;
60-
pub fn sceAudioChangeChannelVolume(channel:i32, left_vol: i32, right_vol:i32) -> i32;
77+
pub fn sceAudioChangeChannelConfig(
78+
channel: i32,
79+
format: AudioFormat,
80+
) -> i32;
81+
pub fn sceAudioChangeChannelVolume(
82+
channel: i32,
83+
left_vol: i32,
84+
right_vol: i32,
85+
) -> i32;
6186
pub fn sceAudioOutput2Reserve(sample_count: i32) -> i32;
6287
pub fn sceAudioOutput2Release() -> i32;
6388
pub fn sceAudioOutput2ChangeLength(sample_count: i32) -> i32;
6489
pub fn sceAudioOutput2OutputBlocking(vol: i32, buf: *mut c_void) -> i32;
6590
pub fn sceAudioOutput2GetRestSample() -> i32;
66-
pub fn sceAudioSRCChReserve(sample_count: i32, freq: AudioOutputFrequency, channels: i32) -> i32;
91+
pub fn sceAudioSRCChReserve(
92+
sample_count: i32,
93+
freq: AudioOutputFrequency,
94+
channels: i32,
95+
) -> i32;
6796
pub fn sceAudioSRCChRelease() -> i32;
6897
pub fn sceAudioSRCOutputBlocking(vol: i32, buf: *mut c_void) -> i32;
6998
pub fn sceAudioInputInit(unknown1: i32, gain: i32, unknown2: i32) -> i32;
7099
pub fn sceAudioInputInitEx(params: *mut AudioInputParams) -> i32;
71-
pub fn sceAudioInputBlocking(sample_count: i32, freq: AudioInputFrequency, buf: *mut c_void);
72-
pub fn sceAudioInput(sample_count: i32, freq: AudioInputFrequency, buf: *mut c_void);
100+
pub fn sceAudioInputBlocking(
101+
sample_count: i32,
102+
freq: AudioInputFrequency,
103+
buf: *mut c_void,
104+
);
105+
pub fn sceAudioInput(
106+
sample_count: i32,
107+
freq: AudioInputFrequency,
108+
buf: *mut c_void,
109+
);
73110
pub fn sceAudioGetInputLength() -> i32;
74111
pub fn sceAudioWaitInputEnd() -> i32;
75112
pub fn sceAudioPollInputEnd() -> i32;

src/psp/ctrl.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub const PSP_CTRL_MS: i32 = 0x2000000;
2424
#[repr(u32)]
2525
pub enum CtrlMode {
2626
Digital = 0,
27-
Analaog
27+
Analaog,
2828
}
2929

3030
#[derive(Copy, Clone)]
@@ -34,8 +34,7 @@ pub struct SceCtrlData {
3434
pub buttons: i32,
3535
pub lx: u8,
3636
pub ly: u8,
37-
pub rsrv: [u8;
38-
6],
37+
pub rsrv: [u8; 6],
3938
}
4039

4140
#[derive(Copy, Clone)]
@@ -47,17 +46,33 @@ pub struct SceCtrlLatch {
4746
pub ui_release: u32,
4847
}
4948

50-
extern {
49+
extern "C" {
5150
pub fn sceCtrlSetSamplingCycle(cycle: i32) -> i32;
5251
pub fn sceCtrlGetSamplingCycle(pcycle: *mut i32) -> i32;
5352
pub fn sceCtrlSetSamplingMode(mode: CtrlMode) -> i32;
5453
pub fn sceCtrlGetSamplingMode(pmode: *mut i32) -> i32;
55-
pub fn sceCtrlPeekBufferPositive(pad_data: *mut SceCtrlData, count: i32) -> i32;
56-
pub fn sceCtrlPeekBufferNegative(pad_data: *mut SceCtrlData, count: i32) -> i32;
57-
pub fn sceCtrlReadBufferPositive(pad_data: *mut SceCtrlData, count: i32) -> i32;
58-
pub fn sceCtrlReadBufferNegative(pad_data: *mut SceCtrlData, count: i32) -> i32;
54+
pub fn sceCtrlPeekBufferPositive(
55+
pad_data: *mut SceCtrlData,
56+
count: i32,
57+
) -> i32;
58+
pub fn sceCtrlPeekBufferNegative(
59+
pad_data: *mut SceCtrlData,
60+
count: i32,
61+
) -> i32;
62+
pub fn sceCtrlReadBufferPositive(
63+
pad_data: *mut SceCtrlData,
64+
count: i32,
65+
) -> i32;
66+
pub fn sceCtrlReadBufferNegative(
67+
pad_data: *mut SceCtrlData,
68+
count: i32,
69+
) -> i32;
5970
pub fn sceCtrlPeekLatch(latch_data: *mut SceCtrlLatch) -> i32;
6071
pub fn sceCtrlReadLatch(latch_data: *mut SceCtrlLatch) -> i32;
61-
pub fn sceCtrlSetIdleCancelThreshold(idlereset: i32, idleback: i32) -> i32;
62-
pub fn sceCtrlGetIdleCancelThreshold(idlereset: *mut i32, idleback: *mut i32) -> i32;
72+
pub fn sceCtrlSetIdleCancelThreshold(idlereset: i32, idleback: i32)
73+
-> i32;
74+
pub fn sceCtrlGetIdleCancelThreshold(
75+
idlereset: *mut i32,
76+
idleback: *mut i32,
77+
) -> i32;
6378
}

src/psp/display.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@ pub enum DisplaySetBufSync {
2222
NextFrame = 1,
2323
}
2424

25-
extern {
26-
pub fn sceDisplaySetMode(mode: DisplayMode, width: usize, height: usize) -> u32;
27-
pub fn sceDisplayGetMode(pmode: *mut i32, pwidth: *mut i32, pheight: *mut i32) -> i32;
25+
extern "C" {
26+
pub fn sceDisplaySetMode(
27+
mode: DisplayMode,
28+
width: usize,
29+
height: usize,
30+
) -> u32;
31+
pub fn sceDisplayGetMode(
32+
pmode: *mut i32,
33+
pwidth: *mut i32,
34+
pheight: *mut i32,
35+
) -> i32;
2836
pub fn sceDisplaySetFrameBuf(
2937
top_addr: *const u8,
3038
buffer_width: usize,

src/psp/ge.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ pub struct GeContext {
99
#[derive(Copy, Clone)]
1010
#[repr(C)]
1111
pub struct GeStack {
12-
pub stack: [u32;8]
12+
pub stack: [u32; 8],
1313
}
1414

1515
#[derive(Copy, Clone)]
1616
#[repr(C)]
1717
pub struct GeCallbackData {
18-
pub signal_func: Option<extern fn(id: i32, arg: *mut c_void)>,
18+
pub signal_func: Option<extern "C" fn(id: i32, arg: *mut c_void)>,
1919
pub signal_arg: *mut c_void,
20-
pub finish_func: Option<extern fn(id: i32, arg: *mut c_void)>,
20+
pub finish_func: Option<extern "C" fn(id: i32, arg: *mut c_void)>,
2121
pub finish_arg: *mut c_void,
2222
}
2323

@@ -33,7 +33,7 @@ pub struct GeListArgs {
3333
#[derive(Copy, Clone)]
3434
#[repr(C)]
3535
pub struct GeBreakParam {
36-
pub buf: [u32;4]
36+
pub buf: [u32; 4],
3737
}
3838

3939
#[derive(Copy, Clone)]
@@ -325,7 +325,7 @@ pub enum GeCommand {
325325
NopFF = 0xff,
326326
}
327327

328-
extern {
328+
extern "C" {
329329
pub fn sceGeEdramGetSize() -> u32;
330330
pub fn sceGeEdramGetAddr() -> *mut u8;
331331
pub fn sceGeEdramSetAddrTranslation(width: i32) -> i32;
@@ -335,12 +335,17 @@ extern {
335335
pub fn sceGeSaveContext(context: *mut GeContext) -> i32;
336336
pub fn sceGeRestoreContext(context: *const GeContext) -> i32;
337337
pub fn sceGeListEnQueue(
338-
list: *const c_void,
339-
stall: *mut c_void,
340-
cbid: i32,
341-
arg: *mut GeListArgs,
338+
list: *const c_void,
339+
stall: *mut c_void,
340+
cbid: i32,
341+
arg: *mut GeListArgs,
342+
) -> i32;
343+
pub fn sceGeListEnQueueHead(
344+
list: *const c_void,
345+
stall: *mut c_void,
346+
cbid: i32,
347+
arg: *mut GeListArgs,
342348
) -> i32;
343-
pub fn sceGeListEnQueueHead(list: *const c_void, stall: *mut c_void, cbid: i32, arg: *mut GeListArgs) -> i32;
344349
pub fn sceGeListDeQueue(qid: i32) -> i32;
345350
pub fn sceGeListUpdateStallAddr(qid: i32, stall: *mut c_void) -> i32;
346351
pub fn sceGeListSync(qid: i32, sync_type: i32) -> GeListState;

src/psp/gu.rs

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
use super::{
2-
c_void,
3-
ge::{GeContext, GeCommand, GeListState},
4-
display::DisplayPixelFormat,
5-
types::{ScePspFMatrix4, ScePspFVector3, ScePspIMatrix4},
2+
c_void, DisplayPixelFormat, GeCommand, GeContext, GeListState,
3+
ScePspFMatrix4, ScePspFVector3, ScePspIMatrix4,
64
};
75

6+
pub type GuCallback = Option<extern "C" fn(id: i32, arg: *mut c_void)>;
7+
pub type GuSwapBuffersCallback =
8+
Option<extern "C" fn(display: *mut *mut c_void, render: *mut *mut c_void)>;
9+
810
pub const GU_PI: f32 = 3.141593;
911

1012
#[repr(u32)]
@@ -411,14 +413,24 @@ pub enum ClutPixelFormat {
411413
Psm8888 = 3,
412414
}
413415

414-
pub type GuCallback = Option<extern fn(id: i32, arg: *mut c_void)>;
415-
pub type GuSwapBuffersCallback = Option<extern fn(display: *mut *mut c_void, render: *mut *mut c_void)>;
416-
417-
extern {
416+
extern "C" {
418417
pub fn sceGuDepthBuffer(zbp: *mut c_void, zbw: i32);
419-
pub fn sceGuDispBuffer(width: i32, height: i32, dispbp: *mut c_void, dispbw: i32);
420-
pub fn sceGuDrawBuffer(psm: DisplayPixelFormat, fbp: *mut c_void, fbw: i32);
421-
pub fn sceGuDrawBufferList(psm: DisplayPixelFormat, fbp: *mut c_void, fbw: i32);
418+
pub fn sceGuDispBuffer(
419+
width: i32,
420+
height: i32,
421+
dispbp: *mut c_void,
422+
dispbw: i32,
423+
);
424+
pub fn sceGuDrawBuffer(
425+
psm: DisplayPixelFormat,
426+
fbp: *mut c_void,
427+
fbw: i32,
428+
);
429+
pub fn sceGuDrawBufferList(
430+
psm: DisplayPixelFormat,
431+
fbp: *mut c_void,
432+
fbw: i32,
433+
);
422434
pub fn sceGuDisplay(state: bool) -> bool;
423435
pub fn sceGuDepthFunc(function: DepthFunc);
424436
pub fn sceGuDepthMask(mask: i32);
@@ -446,9 +458,16 @@ extern {
446458
pub fn sceGuCallList(list: *const c_void);
447459
pub fn sceGuCallMode(mode: i32);
448460
pub fn sceGuCheckList() -> i32;
449-
pub fn sceGuSendList(mode: GuQueueMode, list: *const c_void, context: *mut GeContext);
461+
pub fn sceGuSendList(
462+
mode: GuQueueMode,
463+
list: *const c_void,
464+
context: *mut GeContext,
465+
);
450466
pub fn sceGuSwapBuffers() -> *mut c_void;
451-
pub fn sceGuSync(mode: GuSyncMode, behavior: GuSyncBehavior) -> GeListState;
467+
pub fn sceGuSync(
468+
mode: GuSyncMode,
469+
behavior: GuSyncBehavior,
470+
) -> GeListState;
452471
pub fn sceGuDrawArray(
453472
prim: GuPrimitive,
454473
vtype: i32,
@@ -478,7 +497,12 @@ extern {
478497
pub fn sceGuLightAtt(light: i32, atten0: f32, atten1: f32, atten2: f32);
479498
pub fn sceGuLightColor(light: i32, component: i32, color: u32);
480499
pub fn sceGuLightMode(mode: LightMode);
481-
pub fn sceGuLightSpot(light: i32, direction: &ScePspFVector3, exponent: f32, cutoff: f32);
500+
pub fn sceGuLightSpot(
501+
light: i32,
502+
direction: &ScePspFVector3,
503+
exponent: f32,
504+
cutoff: f32,
505+
);
482506
pub fn sceGuClear(flags: i32);
483507
pub fn sceGuClearColor(color: u32);
484508
pub fn sceGuClearDepth(depth: u32);
@@ -500,7 +524,12 @@ extern {
500524
dest_fix: u32,
501525
);
502526
pub fn sceGuMaterial(components: i32, color: u32);
503-
pub fn sceGuModelColor(emissive: u32, ambient: u32, diffuse: u32, specular: u32);
527+
pub fn sceGuModelColor(
528+
emissive: u32,
529+
ambient: u32,
530+
diffuse: u32,
531+
specular: u32,
532+
);
504533
pub fn sceGuStencilFunc(func: StencilFunc, ref_: i32, mask: i32);
505534
pub fn sceGuStencilOp(
506535
fail: StencilOperation,
@@ -529,10 +558,21 @@ extern {
529558
pub fn sceGuTexFilter(min: TextureFilter, mag: TextureFilter);
530559
pub fn sceGuTexFlush();
531560
pub fn sceGuTexFunc(tfx: TextureEffect, tcc: TextureColorComponent);
532-
pub fn sceGuTexImage(mipmap: MipmapLevel, width: i32, height: i32, tbw: i32, tbp: *const c_void);
561+
pub fn sceGuTexImage(
562+
mipmap: MipmapLevel,
563+
width: i32,
564+
height: i32,
565+
tbw: i32,
566+
tbp: *const c_void,
567+
);
533568
pub fn sceGuTexLevelMode(mode: TextureLevelMode, bias: f32);
534569
pub fn sceGuTexMapMode(mode: TextureMapMode, a1: u32, a2: u32);
535-
pub fn sceGuTexMode(tpsm: TexturePixelFormat, maxmips: i32, a2: i32, swizzle: i32);
570+
pub fn sceGuTexMode(
571+
tpsm: TexturePixelFormat,
572+
maxmips: i32,
573+
a2: i32,
574+
swizzle: i32,
575+
);
536576
pub fn sceGuTexOffset(u: f32, v: f32);
537577
pub fn sceGuTexProjMapMode(mode: TextureProjectionMapMode);
538578
pub fn sceGuTexScale(u: f32, v: f32);
@@ -541,7 +581,12 @@ extern {
541581
pub fn sceGuTexSync();
542582
pub fn sceGuTexWrap(u: GuTexWrapMode, v: GuTexWrapMode);
543583
pub fn sceGuClutLoad(num_blocks: i32, cbp: *const c_void);
544-
pub fn sceGuClutMode(cpsm: ClutPixelFormat, shift: u32, mask: u32, a3: u32);
584+
pub fn sceGuClutMode(
585+
cpsm: ClutPixelFormat,
586+
shift: u32,
587+
mask: u32,
588+
a3: u32,
589+
);
545590
pub fn sceGuOffset(x: u32, y: u32);
546591
pub fn sceGuScissor(x: i32, y: i32, w: i32, h: i32);
547592
pub fn sceGuViewport(cx: i32, cy: i32, width: i32, height: i32);

src/psp/gum.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use super::{c_void, ScePspFMatrix4, ScePspFVector3, MatrixMode, GuPrimitive};
1+
use super::{c_void, GuPrimitive, MatrixMode, ScePspFMatrix4, ScePspFVector3};
22

3-
extern {
3+
extern "C" {
44
pub fn sceGumDrawArray(
55
prim: GuPrimitive,
66
v_type: i32,
@@ -40,7 +40,11 @@ extern {
4040
pub fn sceGumFullInverse();
4141
pub fn sceGumLoadIdentity();
4242
pub fn sceGumLoadMatrix(m: &ScePspFMatrix4);
43-
pub fn sceGumLookAt(eye: &ScePspFVector3, center: &ScePspFVector3, up: &ScePspFVector3);
43+
pub fn sceGumLookAt(
44+
eye: &ScePspFVector3,
45+
center: &ScePspFVector3,
46+
up: &ScePspFVector3,
47+
);
4448
pub fn sceGumMatrixMode(mode: MatrixMode);
4549
pub fn sceGumMultMatrix(m: &ScePspFMatrix4);
4650
pub fn sceGumOrtho(
@@ -49,7 +53,7 @@ extern {
4953
bottom: f32,
5054
top: f32,
5155
near: f32,
52-
far: f32
56+
far: f32,
5357
);
5458
pub fn sceGumPerspective(fovy: f32, aspect: f32, near: f32, far: f32);
5559
pub fn sceGumPopMatrix();

0 commit comments

Comments
 (0)