Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ponut64

Pages: 1 ... 3 4 [5] 6 7 ... 12
61
General Jo Engine Help / Re: Request for real hardware tests
« on: July 05, 2018, 09:58:30 pm »
Okay. I got it working. The first time, I pressed on the directional pad and the game froze. The second time, at 1:43, the audio went into a feedback loop. I didn't get any static before that. It just kept playing that second of the audio over and over.


Interesting. Well, at about 1:43 in, it's just gonna crap itself. and yeah, don't touch the D-pad (or the Z key), it can try to manipulate model data for animation that doesn't exist.
I'm not sure how to organize the transfer at V-blank. I'll have to investigate.
I guess I will have to, since I don't want some 400 KB of LWRAM eaten up by sound.
Music, though... I'm certain I can get that figured out and it's not an issue to use LWRAM as the music buffer.

Thanks, everyone. We can move on now !
Interestingly, the fault area corresponds to memory address 6,266,880 + LWRAM = 8364032 / 0x7FA000 --> End of Saturn memory map.
So now we know what's happening. Now I need to figure out how or if I can offset the SGL PCM playback pointer.

62
General Jo Engine Help / Re: Request for real hardware tests
« on: July 05, 2018, 09:16:35 pm »
Multiple ISOs? Run clean.bat, make sure nothing is mounted
On top of the updated files

63
General Jo Engine Help / Re: Request for real hardware tests
« on: July 05, 2018, 09:02:44 pm »
You should be able to just delete line 20 of ZT Cd (g_stm_work), "PCM_Init", "STM_Init", and "PCM_DeclareUseAdpcm" as those are SBL functions that I do not use (they are in there because I was testing it). They have no effect on the function of the program. I recommend anyone who builds the program do the same. (.. They also could have been interfering)
Thanks for trying to work with me. And before you waste more CD-Rs, I recommend doing preliminary testing using Bizhawk, and if that works, then move on to real hardware.

And, actually: It didn't run out of PCM memory. You can't actually store PCM files themselves in sound memory; think of it more as a playback buffer. It ran out of LWRAM (1MB).
19 sectors (38 KB) of sound RAM is consumed by the sound driver.
There's only about 16 sectors (32 KB) of PCM playback buffer (8 sectors for mono, 16 sectors for stereo).
And for some reason they have a whopping 436 KB dedicated to "pitch/sequence" . .

64
General Jo Engine Help / Re: Request for real hardware tests
« on: July 05, 2018, 07:32:03 pm »
I actually use Pseudo Saturn Kai Lite to boot CD-Rs.
That's interesting. We have one where it won't boot, two where it destroys you, and emulators that just don't do anything wrong (well most do, only works right in Bizhawk.. and mostly on real hardware if it were not for the static).

I'm uploading a zip package to where anyone can re-build the ISO. I do have a modified engine, after all. I imagine it freezes because the display mode changes (to 352x240).
http://www.mediafire.com/file/nr88ibobuw2vyy4/buildit.zip/file
By the way, you can target the code to AIFF files. It just doesn't know what to do with the header. Always encode 16-bit mono at 30.72KHz.

65
General Jo Engine Help / Re: Request for real hardware tests
« on: July 05, 2018, 06:34:01 pm »
Saturn MK-80 000 A
SERIAL AE66078526
Manufactured September 1996 MALAYSIA
"US Model 2"

DO NOTE: My Saturn is a strange one.
Internally, the plastic shell has the hook for the Model 1-type CD open sensor, as well as what looks to be mounting points for the Model 1 CD activity light acrylic light tube.
The CD Drive is distinctly a later model Saturn. The CD OPEN sensor is the gear-switch type (no cable). The CD door has a different plastic finish than the rest of the console (it's a darker black).
Only one or two out of the five screwholes on the bottom actually screw in to the top half of the Saturn; I'm pretty sure the top half has 6 screw holes actually in it, and I'm afraid if I pick the console up wrong that I will rip the top off. There's also some other strange cavity in the bottom of the console that shines onto the back of a PCB on the right side of the console.

I bought my first Saturn (and had my first experience with it!) early in 2018, so my guess is my Saturn is cobbled together parts from broken units.
Personally, I am suspicious of it and think that internally it's probably a Model 1 more than a Model 2, but it does have BIOS Rev 1.01 / 1995. I say that because the eBay seller I bought it from clearly had pictures showing a Model 1 Saturn (and a Model 2 controller, which I got) and my guess is he broke it and hastily slapped a shell from a broken console on it. And I can tell some work and care was given to it, since when I received it, there was a cloth shim in the backup RAM battery preventing unnecessary battery usage/leakage. But you know, he jipped me a bit, because this thing is a mismatch!

66
General Jo Engine Help / Re: Request for real hardware tests
« on: July 05, 2018, 09:21:42 am »
Stopping the song is easy that's not a problem. More to my point since I have the static issue, I don't feel like fixing the song ending.
That static though, that's a problem!
Thanks for testing. Now I know it's not just my Saturn. My real concern is testing a fix for it... I only have so many CD-Rs...

By the way, in my experience, the most accurate emulator for SGL PCM testing is Bizhawk (Saturnus based).
The other emulators do not playback the stream at the correct pitch rate.

67
General Jo Engine Help / Request for real hardware tests
« on: July 05, 2018, 07:38:21 am »
Hey guys,

I just want to know if you run this ISO if the sound eventually annihilates your sanity (with static, of course).
It would only ever do this on real hardware. You can test emulators if you want, but about all you will get are some skips and the end of the file not terminating the sound.

http://www.mediafire.com/file/gvvevvruvr4cwnb/sl_coff.iso
----------------------------------------------------------------------------------------------------------------------------------------------
"But!" you may ask, "what is this?!"
This is streamed PCM playback of 30720 Hz (30.72KHz) audio using SGL, with the sound effect itself being copied straight to the PCM playback buffer.
Is this useful? Hell man, I don't know! But this actually plays sound, so it's what I have to work with because I cannot for the life of me get SBL to play any sound at all.

"What is the problem?"
I'm not sure. It could be a limitation of SGL. It could be a hardware limitation that SBL circumvents. It could just be my Saturn. But after so long of playing back the file, static gets thrown into the mix and I do not know how to suppress it.
Theories:
- SGL PCM playback pointer moves to a region of memory that has bad data
- SGL PCM playback pointer eventually starts playing back the incomplete data in LWRAM as its being copied
- SGL PCM playback pointer eventually leaves the Saturn's entire possible memory map range, returning NULL data
- A-bus and B-bus DMA processes eventually cross-corrupt
- SGL PCM playback library eventually attempts to mux PCM sound outputs, resulting in garbage added
Things I have tried:
- Attempt to move SGL playback start pointer (You cannot, slPCMOn will not change its parameters once started)
- Using NULL for PCM data region (I don't want it to point to any region, since I am copying the PCM data directly to the PCM buffer) (Result: Garbage)
- Using end-of-memory for PCM data region (Result: Crash)
- Different DMA modes
- Not much else (only one song and bitrate on real hardware)
MAJOR ISSUE:
No emulators replicate this problem.

Relevant code:
Code: [Select]

#ifndef __AUDIO_H__
#define __AUDIO_H__

#define SECTOR_SIZE     (2048)
#define RING_BUF_SIZE  (2048*10)
#define PCM_ADDR  ((void*)0x25a20000)
#define PCM_SIZE  (4096*2)

#define SMP_1TASK_SAMPLE (1024)
#define SMP_TR_MODE_CD (PCM_TRMODE_CPU)
#define SMP_LOAD_NUM (10)

#define PCMRAM (631734272)
#define LWRAM (2097152)
#define HIMEM (100679680)
//(31122)
#define S4410KHZ     (0)
#define S3780KHZ     (31451)
//THIS IS TESTED
#define M3072KHZ     (31118)
//
#define S2205KHZ     (30720)
#define S1920KHZ (29431)
#define S18900HZ     (29404)
#define S1600KHZ     (29134)
#define S1536KHZ     (29074)
#define S1100KHZ     (27643)
#define S0800KHZ     (27086)


extern jo_sound     main_pcmfx;
extern jo_sound music_pcmfx;

//Functions go here
void pcm_music_play(void(*sysframe)(void));
void* load_pcm(Sint8* filename, const jo_sound_mode mode, jo_sound *sound, void * workAddress);
void sound_on_channel(jo_sound * const sound, const unsigned char channel);
#endif



//Modified Jo Engine functions
jo_sound music_pcmfx;
jo_sound main_pcmfx;

static PCM _pcm[JO_SOUND_MAX_CHANNEL] =
{
    {(_Stereo | _PCM16Bit), 0, 127, 0, 0x0, 0, 0, 0, 0},
    {(_Stereo | _PCM16Bit), 2, 127, 0, 0x0, 0, 0, 0, 0},
    {(_Stereo | _PCM16Bit), 4, 127, 0, 0x0, 0, 0, 0, 0},
    {(_Stereo | _PCM16Bit), 6, 127, 0, 0x0, 0, 0, 0, 0},
    {(_Stereo | _PCM16Bit), 8, 127, 0, 0x0, 0, 0, 0, 0},
    {(_Stereo | _PCM16Bit), 10, 127, 0, 0x0, 0, 0, 0, 0},
};

static Sint16 music_frames = 0;
static Sint16 music_sectors = 0;

void pcm_music_play(void(*sysframe)(void))
{
//DEBUG INFORMATION
Sint8* filename = "B.PCM";
    music_pcmfx.mode = JoSoundMono16Bit;
//This function is supposed to play a mono PCM sound effect constantly.
//Some LWRAM is consumed in the process (10 sectors / 20KB).
    void* pcm = LWRAM;
void* write_buffer = LWRAM;
Sint32 fid = GFS_NameToId(filename);
GfsHn gfsm = GFS_Open(fid);
Sint8 fetch_timer = 0;
Sint32 fsize;
Sint32 nsct;
Sint32 stat;
Sint32 rdsize;
//Rate of data reading
Sint16 rt_step = (2 * 2048);
Sint16 rt_sector = 2;
//Get sectors
//HEY! SBL DOCUMENTATION IS WRONG! THIRD ITEM nzect IS GFS SECTOR COUNT. SECOND ITEM IS CD SECTOR SIZE.
//TIP: MEMORY MUST BE MANAGED IN SECTORS (2KB)
GFS_GetFileSize(gfsm, NULL, &nsct, NULL);
GFS_GetFileInfo(gfsm, NULL, NULL, &fsize, NULL);
//This determines playback time?
music_pcmfx.data_length = (fsize);
_pcm[(int)0].mode = (Uint8)music_pcmfx.mode;
_pcm[(int)0].pitch = M3072KHZ;
//How many frames are we reading?
if(rt_step < fsize){
music_sectors = (fsize + (rt_step - 1))/(rt_step);
}
jo_printf(0, 18, "(%i)", fsize);

GFS_SetReadPara(gfsm, rt_step);
GFS_SetTransPara(gfsm, rt_sector);
GFS_SetTmode(gfsm, GFS_TMODE_CPU);
//Loading follows
GFS_NwCdRead(gfsm, (10 * 2048));
for( ; music_frames <= music_sectors ; ){
//Copy memory from work area buffer directly into the PCM stream buffer
slDMACopy(write_buffer, PCMRAM, (8 * 2048));
slDMAWait();
//Very tightly timed! Not even timed right! Saturn appears to playback sounds faster than advertised; check pitch?
fetch_timer++;
if(music_frames < 4){
GFS_NwFread(gfsm, rt_sector, write_buffer + (music_frames * rt_step), rt_step);
}
do{
sysframe();
slSynch();
if(music_frames < 4){
GFS_NwExecOne(gfsm);
GFS_NwGetStat(gfsm, &stat, &rdsize);
}
jo_printf(0, 7, "(%i)", music_frames);
jo_printf(7, 7, "(%i)", music_sectors);
jo_printf(0, 11, "(%i)", rdsize);
jo_printf(10, 11, "(fetched filesize)");
}while(stat != GFS_SVR_COMPLETED && rdsize < rt_step);
if(music_frames < 4){
music_frames++;
}
if(music_frames == 4 && fetch_timer == 8){
music_frames = 0; fetch_timer = 0;
}
slSndFlush();
music_pcmfx.data = pcm;
jo_printf(0, 0, "(%i)", pcm);
music_pcmfx.current_playing_channel = 0;
//HEY! slPCMOn does -NOT- accept changes to the data address during playback. IT WILL DO NOTHING.
slPCMOn(&_pcm[(int)0], music_pcmfx.data, music_pcmfx.data_length);
slPCMParmChange(&_pcm[(int)0]);
}
GFS_Close(gfsm);
}



68
Have you checked the modules in the makefile?
Has anything you commented out to get the Shooter demo to work broken the other demo?
Have you tried removing the "static" definition from all the variables?

Have you tried including the header in the storyboard file?
Have you tried putting something like the following in the header file?

Code: [Select]
// A custom structure to show that you can use customs as well as jo_2d_object_attributes, jo_pos2D, etc.
typedef struct
{
    /* Must be the first field in our custom structure in order to let the storyboard retrieve where the location of our object is */
    jo_2d_object_attributes     attributes;
    int                         sprite_id;
    // Add other attributes here or not ;)
}                               circular_saw_t;

extern circular_saw_t           saws[2];
extern jo_pos2D                 drone;
extern jo_pos2D                 sentry;

extern int                      sentry_sprite_id;
extern int                      drone_sprite_id;

extern jo_storyboard            *drone_storyboard;


I'm probably not being all that helpful, but next time you have an issue like this, throwing up what you're working with in a zip file (the entire directory) would be helpful.

69
General Jo Engine Help / Re: Can't get Every Day Cute copy to work
« on: July 02, 2018, 10:58:10 pm »
Keep at it! Game development is like research. You could get nothing done for months and then suddenly it works!

70
General Jo Engine Help / Re: Can't get Every Day Cute copy to work
« on: July 02, 2018, 09:23:17 pm »
That's happened to me before. That, and the width of the TGA being wrong. I'm glad you got it working.

71
General Jo Engine Help / Re: Can't get Every Day Cute copy to work
« on: July 02, 2018, 07:47:58 pm »
Instead of worrying yourself with how Jo Engine manages textures through included header and C files, I would advise you investigate XL2's Image and Model converters.
These allow you to convert images to binary files that can be loaded and overwritten on-demand. Animated textures though are something TBD, but if you are dealing with a sprite-based game, you can easily create an animated sprite structure with a unique sprite texture for each frame and a way to flip between them.
You can find these tools elsewhere on the forum.

Otherwise, the only thing I can think of is your directory structure is messing things up and you might want to try putting everything in root.

72
Don't worry, I'm going to move forward with SGL. I did set the volume. Did a "rollback" and checked Yabause sound channels, nothing was playing. This isn't for ADPCM either, I've concluded I don't need that (though I do wonder how the ADP_DecMono / ADP_DecStereo functions work).
I've found a solution so now I just have to organize it. If I come back to needing SBL, well, I'll have to try and use a more isolated program to use it.
Thanks for reading.

73
An update:

There's actually a "Pitch" value in SGL sound effects that you can manipulate to play the sound back at different rates.
I did see this before I looked at the Rockin'Bs code, but I hadn't figured out how to manipulate it. I don't think I ever would have, it's really complex.
This unfortunately does not comply directly with a sample rate.

Fortunately Rockin'B has some code that can take an input sample rate, and convert that to an output pitch for SGL sound.
This is pretty dang useful, but it uses double-precision values so the Saturn cannot compute it itself (plus, where would you even know the sample rate?)

To get around that, I just used an online C compiler. With that, I can generate a table of common sample rates and convert those to pitch rates.

Code: [Select]
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define PCM_toPitch(OCT, FNS)   ((FNS & 0x03FF) | ((OCT & 0xF) << 11))
#define PCM_toOCT(pitch)        ((pitch & 0x7800) >> 11)
#define PCM_TIMES   1.000577789
// SOURCE: The Rockin' B, Rockin' B Saturn Libraries, RB_PCM.C, line 766
unsigned short PCM_computePitch(double sampleRate)
{
    double c, s;
    int OCT, FNS;
   
    // Fn = Fo * 2^(n/1200)

    // compute necessary slowdown / speedup
    // assuming a base frequency of 44100 Hz
    // Fn / Fo = 2^(n/1200)
    // with Fo = 44100 Hz, the saturn base sample frequency
    s = sampleRate / 44100.0;
//    printf("s = %f\n", s);
   
    // compute the pitch to this(cents)
//    n = log(s) / log(PCM_TIMES);
    // log2(Fn / Fo) * 1200 = n
    c = (log(s) / log(2)); // * 1200.0;
//    printf("c1 = %f\n", c);
    if(c >= 0) {
        // compute OCT
        OCT = (int)c;
        // compute FNS
        c -= (double)OCT;
       
    } else {
        // compute OCT
        OCT = (int)c;
        if(c < OCT)
            OCT -= 1;
        // compute FNS
        c = c - ((double)OCT);
            // respect to new base frequency
//        s = sampleRate / (44100.0 / (1 - OCT));
            // n is now >= 0
//        c = (log(s) / log(2));
    }
   
    OCT &= 0xF;
//    printf("OCT = %x\n", OCT);
    // compute FNS
    c *= 1200.0;
//    printf("c2 = %f\n", c);
        // remove OCT from cents,
        // it's a seperate value
        // the argument needs to be in range 0 <= a < 1200
//    printf("(c / 1200.0) = %f\n", (c / 1200.0));
//    printf("(double)((int)(c / 1200.0)) = %f\n", (double)((int)(c / 1200.0)));
//    printf("pow arg = %f\n", (c / 1200.0) - (double)((int)(c / 1200.0)));
//    printf("pow() = %f\n", pow(2, (c / 1200.0) - (double)((int)(c / 1200.0))));
    FNS = ((int)(1024.0 * (pow(2, (c / 1200.0) ) - 1.0))) & 0x3FF;
//    printf("FNS = %i\n", FNS);
// interpret
//    return ((int)(1024.0 * (pow(2, c/1200.0) - 1.0))) & (0x3FF + (0xF << 11));
   
    return PCM_toPitch(OCT, FNS);
}


void main(void){
int Rate = 18900;
int Pitch;
Pitch = PCM_computePitch(Rate);
printf("(%i)", Pitch);
}

On this website: https://www.onlinegdb.com/online_c_compiler

You can modify the sound data like this:
   __jo_internal_pcm[(int)channel].pitch = [pitch number];

Table of simple rates:
Code: [Select]
44.10 KHz     0 Pitch
37.80 KHz     (31451) Pitch
30.72 KHz     (31122) Pitch
22.05 KHz     (30720) Pitch
18.90 KHz     (29403) Pitch
16.00 KHz     (29134) Pitch
11.00 KHz     (27643) Pitch
08.00 KHz     (27086) Pitch

With this, you can play sound at any sample rate using SGL.
And I should be able to continue my efforts and forge some sort of sound-streaming system using it.
Well, since I got the SBL STM library to cooperate, maybe? Probably not...

On another note: Why did I finally give up on SBL PCM-ADPCM library?
Well, I got it to run playback code errorless, meaning it did not report an error playing back the sound.
But it did not play any sound, even on real hardware, with the interrupt registered. So I had nowhere left to go. Code was Errorless, crashless code that doesn't work is the worst. And you know that's what most game bugs are...

74
A "static" variable becomes read-only. You can generally avoid using this.
I would guess the compiler is complaining about redefinition of e_ship because the type is not static but your variable is. Plus, you should put the following line in the .h file.
Code: [Select]
extern e_ship enemy;
You use extern to notify another document (especially ones compiled separately) that this variable exists, though you do not define the variable's contents with extern.

I generally avoid using "char" variables, if you can remember the state with integers, you should use integers (S or U int 8/16/32, depending on how much bit depth you need and whether or not you need negative values)

If your function code is not meant to return data to a variable, its return type should be "void".
Code: [Select]
inline bool         explodeEnemy(jo_node *node);
just becomes
void explodeEnemy(jo_node *node);
You generally see a lot of programmers use bool as a function return type so the function can return TRUE or FALSE depending on successful or unsuccessful execution of the intended result. You haven't written in those conditions; you don't need to.

"Display" is in fact undefined in the SGL and SBL libraries; you need to define what "Display" means in terms of SGL or SBL.
Do you mean debug information? If so you would be looking at "jo_printf" or "slPrintFX".




Also, programming is gonna take a long time. Welcome to the club.

75
Well, I need* both. Looking at what you have done (assuming it uses SBL PCM!) couldn't hurt, because I can't fathom why this code is not working when compared against Rockin'Bs sound player.
I would hope that I don't need to straight-up copy something, so I say, hold the thought for now.
In time, I expect to get something working. Got to be simple.

/e:
Interesting.
STM handle does not return an error, yet it plays no sound. Very odd.
This time, I have registered the interrupt.
Code: [Select]
void	my_vlank(void){
PCM_VblIn();
//Put gouraud shade table in place
    slGouraudTblCopy();
}
//and in main
slIntFunction(my_vlank);

Pages: 1 ... 3 4 [5] 6 7 ... 12
SMF spam blocked by CleanTalk