As I proposed to Ayla and DarkstackDev, here is the code I use to test the custom resolution settings :
EDIT : ONLY TO TEST ON VGA
Code:
/*
File : resolution.c
Let's test the resolution !
*/
#include <stdio.h>
#include <stdlib.h>
#include <dc/pvr.h>
#include <dc/maple.h>
#include <dc/maple/controller.h>
#include <png/png.h>
#include <dc/video.h>
static pvr_ptr_t txr;
int loadImage(int *l, char *fichier,int taille,int transparence,int flou) {
int tr;
int im;
if (transparence) tr=PNG_FULL_ALPHA; else tr=PNG_NO_ALPHA;
*l= (int)((int *) (pvr_mem_malloc(taille * taille * 2)));
im=png_to_texture(fichier,(int *) *l ,tr);
return 1;
}
void Draw(
pvr_ptr_t texture,
int x1,
int y1,
int x2,
int y2,
int a,
int r,
int g,
int b,
int transparence,
int taille,
double z)
{
pvr_poly_cxt_t cxt;
pvr_poly_hdr_t hdr;
pvr_vertex_t vert;
int tr;
int couleur;
double m1=0,m2=1,min=0,max=1;
if (transparence) {tr=PVR_LIST_TR_POLY; couleur=PVR_TXRFMT_ARGB4444;} else {tr=PVR_LIST_OP_POLY; couleur=PVR_TXRFMT_RGB565;}
pvr_poly_cxt_txr(&cxt, tr, couleur, taille,taille, texture,0);
cxt.txr.uv_clamp = PVR_UVCLAMP_NONE;
cxt.gen.culling = PVR_CULLING_NONE;
pvr_poly_compile(&hdr, &cxt);
pvr_prim(&hdr, sizeof(hdr));
vert.argb = PVR_PACK_COLOR (((double)a / 255),((double)r / 255),((double)g / 255),((double)b / 255));
vert.oargb = 0;
vert.flags = PVR_CMD_VERTEX;
vert.x = x1;
vert.y = y1;
vert.z = z;
vert.u = m1;
vert.v = min;
pvr_prim(&vert, sizeof(vert));
vert.x = x2;
vert.y = y1;
vert.z = z;
vert.u = m2;
vert.v = min;
pvr_prim(&vert, sizeof(vert));
vert.x = x1;
vert.y = y2;
vert.z = z;
vert.u = m1;
vert.v = max;
pvr_prim(&vert, sizeof(vert));
vert.x = x2;
vert.y = y2;
vert.z = z;
vert.u = m2;
vert.v = max;
vert.flags = PVR_CMD_VERTEX_EOL;
pvr_prim(&vert, sizeof(vert));
}
int check_start() {
maple_device_t *cont;
cont_state_t *state;
cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
if (cont) {
state = (cont_state_t *)maple_dev_status(cont);
if (!state)
return 0;
if(state->buttons & CONT_START)
return 1;
}
return 0;
}
void do_frame() {
pvr_wait_ready();
pvr_scene_begin();
pvr_list_begin(PVR_LIST_OP_POLY);
Draw(txr,0,0,1024,1024,255,255,255,255,0,1024,0.1f);
pvr_list_finish();
pvr_scene_finish();
}
static pvr_init_params_t pvr_params = {
{ PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16, PVR_BINSIZE_0,
PVR_BINSIZE_0 },
1024* 1024
};
extern uint8 romdisk[];
KOS_INIT_ROMDISK(romdisk);
//TEST 768x480 VGA 60Hz
// DM_768x480_VGA
// my monitor displays 720x576 50Hz
// I can see 720x480;
vid_mode_t vid_768 =
{
DM_768x480,
736, 480,
0,
CT_VGA,
0,
624, 863,
96, 18,
0x18, 0x104,//24,260
0x36, 0x34b,//54,843
0x2c, 0x26c,//44,620
0, 1,
{ 0, 0, 0, 0 }
};
int main(int argc, char *argv[]) {
vid_mode_t vidMode;
printf("---Testing resolution---\n");
printf("Press Start to exit.\n");
/* if you want to test a custom one */
memset( &vidMode, 0, sizeof(vid_mode_t));
memcpy( &vidMode, &vid_768, sizeof(vidMode));
vidMode.pm = PM_RGB565;
vidMode.cable_type = vid_check_cable();
vid_set_mode_ex( &vidMode);
pvr_init(&pvr_params);
vid_set_mode_ex( &vidMode);
/* if you want to test a KOS one */
/*vid_set_mode(DM_768x480_PAL_IL,PM_RGB565);
pvr_init(&pvr_params);
vid_set_mode(DM_768x480_PAL_IL,PM_RGB565);*/
loadImage((int *)((int)&(txr)),"/rd/resol.png",1024,0,0);
/* Go as long as the user hasn't pressed start on controller 1. */
while(!check_start()) {
do_frame();
}
return 0;
}
As you can see I need to set up the resolution before pvr_init and after.
In case you need it, here is the makefile :
Code:
#
# Basic KallistiOS skeleton / test program
# (c)2001 Dan Potter
#
# Put the filename of the output binary here
TARGET = resolution.elf
# List all of your C files here, but change the extension to ".o"
OBJS = resolution.o romdisk.o
all: rm-elf $(TARGET)
include $(KOS_BASE)/Makefile.rules
clean:
-rm -f $(TARGET) $(OBJS) romdisk.*
rm-elf:
-rm -f $(TARGET)
$(TARGET): $(OBJS)
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
$(OBJS) $(OBJEXTRA) -lpng -lz -lm -lkosutils $(KOS_LIBS)
romdisk.img: romdisk/resol.png
$(KOS_GENROMFS) -f romdisk.img -d romdisk -v
romdisk.o: romdisk.img
$(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o
run: $(TARGET)
$(KOS_LOADER) $(TARGET) -n
dist:
rm -f $(OBJS) romdisk.*
$(KOS_STRIP) $(TARGET)
and you need to have the resol.png in a directory "romdisk"
Please post your tests !