main.pp 953 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. program main;
  2. {$apptype arm9}
  3. {$define ARM9}
  4. {$mode objfpc}
  5. uses
  6. nds9, fat;
  7. var
  8. i: integer;
  9. size: u32;
  10. text: string;
  11. handle: P_FILE;
  12. begin
  13. consoleDemoInit();
  14. videoSetMode(MODE_FB0);
  15. vramSetBankA(VRAM_A_LCD);
  16. printf('fatInit()...');
  17. if fatInit(4, true) then
  18. begin
  19. printf(#9 + 'Success' + #10);
  20. handle := fopen('/test1.txt', 'r');
  21. if handle = nil then
  22. begin
  23. printf('Cannot open file' + #10);
  24. end else
  25. begin
  26. fseek(handle, 0, SEEK_END); // Go to end of file
  27. size := ftell(handle); // Get current position in file, because it is the end it will be the size
  28. fseek(handle, 0, SEEK_SET); // Go to begining of file
  29. fread(@text, size, 1, handle); // Read all of file into memory
  30. printf(@text);
  31. fclose(handle); // Close file
  32. end;
  33. end else
  34. printf(#9 + 'Failure' + #10);
  35. for i := 0 to (256 * 192) - 1 do
  36. VRAM_A[i] := RGB15(31,0,0);
  37. while true do;
  38. end.